Sign in to follow this  
Followers 0
usera

Control

14 posts in this topic

Please help me to understand Control

Say, there are 3 notepad windows opened.

in windows 1, it has "windows1" in notepad text body.

in windows 2, it has "windows2" in notepad text body.

in windows 3, it has "windows3" in notepad text body.

Now, how can I use control function to get "windows2" notepad text body instead of windows1 or windows3, and typing more text behind "windows2"

Thanks

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Hi, usera. You don't actually state what you want to do with the control. This would be a quick and dirty example of getting all three window handles...

$var = ControlGetHandle("Untitled", "Windows 1", "Edit1")
$var2 = ControlGetHandle("Untitled", "Windows 2", "Edit1")
$var3 = ControlGetHandle("Untitled", "Windows 3", "Edit1")
MsgBox(0, "", $var & " " & $var2 & " " & $var3)

Edit: I think it is time to update my prescription. I missed the part about typing more text :)

Edited by JLogan3o13

√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

Use WinActivate to make the get the required window the active window:

WinActivate("[CLASS:Notepad]", "windows2")
then use Send to write some text.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Use WinActivate to make the get the required window the active window:

WinActivate("[CLASS:Notepad]", "windows2")
then use Send to write some text.

Thanks water, it works

may I ask for little bit deep?

Say if I have to use CONTROL function, how can I do that?

in you code, you use "windows2" as text, what happend if the notepad body contain lots of text, let say over 2 pages, do i need put all of them here?

usera

Edited by usera

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Use

WinActivate("[CLASS:Notepad; INSTANCE:n]", "")
to select the notepad window by instance number (starting with n = 1).

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Use

WinActivate("[CLASS:Notepad; INSTANCE:n]", "")
to select the notepad window by instance number (starting with n = 1).

Thanks water, how about use CONTROL

Share this post


Link to post
Share on other sites

What do you mean by "Control"?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

What do you mean by "Control"?

CONTROL, something like:

ControlGetHandle("Untitled", "Windows 1", "Edit1")

Share this post


Link to post
Share on other sites

If you have 3 notepad windows you have to find anything to keep them apart.

Either by the window title, a text in any of the controls or by instance.

I wouldn't insist on using any Control function but try to find an attribute to distinguish the windows.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

If you have 3 notepad windows you have to find anything to keep them apart.

Either by the window title, a text in any of the controls or by instance.

I wouldn't insist on using any Control function but try to find an attribute to distinguish the windows.

in my example, only "windows1" "windows 2" "windows 3" which in the notepad text body different, is this the information as a "text" for CONTROL?

do you mind give me the code for this example use CONTROL?

thanks

Share this post


Link to post
Share on other sites

How do you decide in which of the 3 windows you want to enter the additonal text?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

How do you decide in which of the 3 windows you want to enter the additonal text?

Thanks, that is my question, somebody tell me sure use CONTROL, and I like to learn that just do not get idea how to use CONTROL

Share this post


Link to post
Share on other sites

I fear I do not get the point. Is your goal to learn how to use the Control* functions (so your example with 3 notepads is purely hypothetical) or do you have a real problem and need to decide in which of the 3 notepad windows you need to enter text?

If it is number 1 then I would suggest to select another example because the current is overly complicated.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

Use WinActivate to make the get the required window the active window:

WinActivate("[CLASS:Notepad]", "windows2")
then use Send to write some text.

usera

What is wrong with this example?

Just give the Winactivate() function a variable in which to hold the handle (hwnd) and use it as the first param

in your Control* function.

Edited by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0