Autoit Control Get Post Height / Width Using C#
Retrieves the position and size of a control relative to its
window.
ControlGetPos ( "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 an array containing the size and the control's position relative to its client window: |
$array[0] = X position | |
$array[1] = Y position | |
$array[2] = Width | |
$array[3] = Height | |
Failure: | Sets @error 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.
Source : Autoit Help Document
Source Code Autoit Control Get Height / Width in C#
Parameters Required :
Title : [CLASS:Notepad]
Text : ""
Control : Edit1
private void controlGetPosButton_Click(object sender, EventArgs e)
{
//open notepad program
autoit.Run("notepad.exe", "", 1);
//wait notepad opened until 10 seconds
autoit.WinWait("[CLASS:Notepad]", "", 10);
//get height position
int iReturnGetPosHeight = autoit.ControlGetPosHeight("[CLASS:Notepad]", "", "Edit1");
int iReturnGetPosWidth = autoit.ControlGetPosWidth("[CLASS:Notepad]", "", "Edit1");
returnGetPosLabel.Text = "Autoit get control height (x) : " + iReturnGetPosHeight.ToString() + "\n";
returnGetPosLabel.Text += "Autoit get control width (y) : " + iReturnGetPosWidth.ToString() + "\n";
}
Download Full Source Code
Heloo can you reupload this code?
ReplyDelete