Posted by Catur Nugroho | File under :

Autoit Win Active Using C#

Checks to see if a specified window exists and is currently active.
WinActive ( "title" [, "text"] )

Parameters

title The title of the window to check. See Title special definition.
text [optional] The text of the window to check.

Return Value

Success: Returns the handle to the window if it is active.
Failure: Returns 0 otherwise.

Remarks

None.

Source : Autoit Help Document

Autoit Win Active In C#



Parameters Required :
Title : [CLASS:Notepad]
Text : ""
Time Out :

 private void winWaitbutton_Click(object sender, EventArgs e)
        {           
            //open notepad
            autoit.Run("Notepad.exe", "", 1);

            //Wait a maximum of 20 seconds for "[CLASS:Notepad]" to exist
            autoit.WinWait("[CLASS:Notepad]", "", 20);

            if (autoit.WinActive("[CLASS:Notepad]", "") == 0)
            {
                MessageBox.Show("Notepad didn't active");
            }
        }


Download Full Source Code
Posted by Catur Nugroho | File under :

Autoit Win Wait Active Using C#

Pauses execution of the script until the requested window is active.
WinWaitActive ( "title" [, "text" [, timeout]] )

Parameters

title The title of the window to check. See Title special definition.
text [optional] The text of the window to check.
timeout [optional] Timeout in seconds

Return Value

Success: Returns handle to the requested window.
Failure: Returns 0 if timeout occurred.

Remarks

None.

Source : Autoit Help Document

Source Code Autoit Win Wait In C#

 


Parameters Required :
Title : [CLASS:Notepad]
Text : ""
Time Out :

   private void winWaitButton_Click(object sender, EventArgs e)
        {
            DateTime dtStart = DateTime.Now;

            //open notepad
            autoit.Run("Notepad.exe", "", 1);

            //Wait a maximum of 20 seconds for "[CLASS:Notepad]" to exist and be active
            autoit.WinWaitActive("[CLASS:Notepad]", "", 20);

            label1.Text = "waiting for " + (DateTime.Now - dtStart).Seconds.ToString() + " seconds from 10 seconds";
        }


Download Full Source Code (look into source code if the notepad doesn't exist)
Posted by Catur Nugroho | File under :

Autoit Win Wait Using C#

WinWait

Pauses execution of the script until the requested window exists.
WinWait ( "title" [, "text" [, timeout]] )

Parameters
title The title of the window to check. See Title special definition.
text [optional] The text of the window to check.
timeout [optional] Timeout in seconds

Return Value
Success: Returns handle to the requested window.
Failure: Returns 0 if timeout occurred.

Remarks
None.

Source : Autoit Help Document

Source Code Autoit Win Wait In C#


Parameters Required :
Title : [CLASS:Notepad]
Text : ""
Time out :

        private void winWaitButton_Click(object sender, EventArgs e)
        {
            DateTime dtStart = DateTime.Now;

            //open notepad
            autoit.Run("Notepad.exe", "", 1);

            //Wait a maximum of 20 seconds for "[CLASS:Notepad]" to exist
            autoit.WinWait("[CLASS:Notepad]", "", 20);

            label1.Text = "waiting for " + (DateTime.Now - dtStart).Seconds.ToString() + " seconds";
        }


Download Full Source Code (look into source code if the notepad doesn't exist)
Posted by Catur Nugroho | File under :

Autoit Control List View Using C#


Sends a command to a TreeView32 control.
ControlTreeView ( "title", "text", controlID, "command" [, option1 [, option2]] )

Parameters

title The title of the window to access.
text The text of the window to access.
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

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


References can also be mixed like "Heading1|#1".

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.

Source : Autoit Help Document
Posted by Catur Nugroho | File under :

Autoit Control Show Using C#

Shows a control that was hidden.
ControlShow ( "title", "text", controlID )

Parameters

title The title of the window to access.
text The text of the window to access.
controlID The control to interact with. See Controls.

Return Value

Success: Returns 1.
Failure: Returns 0 if window/control is not found.

Remarks

None.

Source : Autoit Help Document

Source Code Autoit Control Show In C#



Parameters Required :
Title : [CLASS:Notepad]
Text : ""
Control : Edit1

private void controlShowButton_Click(object sender, EventArgs e)
        {
            //open notepad program
            autoit.Run("notepad.exe", "", 1);

            //wait notepad opened until 10 seconds
            autoit.WinWait("[CLASS:Notepad]", "", 10);

            //hide text area
            autoit.ControlHide("[CLASS:Notepad]", "", "Edit1");
            Thread.Sleep(2000);

            //show text area
            autoit.ControlShow("[CLASS:Notepad]", "", "Edit1");
        }


Download Full Source Code