Sign in to follow this  
Followers 0
Orao

How to get Tittle and Text of an actieve window?

9 posts in this topic

How can i tell the script to write down just the first 2 words of the $text (not the whole text, because sometimes its very long)?:

I would like to make a script that will automatically get Tittle and Text of an active Window, the same way that the au3recorder.exe does, cause the au3Recorder.exe is sometimes not working correctly.

so i have tried the following script:

Local $title = WinGetTitle("[active]", "")

Local $text = WinGetText("[active]", "")
Run("C:\Program Files (x86)\AutoIt3\SciTE\scite.exe")
sleep(2000)

SEND ( $title, $text)

But how can i tell the script to write down just the first 2 words of the $text (not the whole text, because sometimes its very long)?

Share this post


Link to post
Share on other sites



Try your luck with StrinFunctions, StringSplit or Regex functions. Should not be very hard to do.


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

But how can i tell the script to write down just the first 2 words of the $text (not the whole text, because sometimes its very long)?

The StringSplit() function can be used, like this,

$sText = "This is not too a long line of text"
$aText = StringSplit($sText, ' ')
ConsoleWrite($aText[1] & " " & $aText[2] & @LF)

- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Thanks, but i still didnt manage:

Is there a way how i can Get text from active window, but just line by line, because when i do it with

WinGetText("[active]", "")

Then i get all the text lines together, and there is no space between the lines:

for example:

Installation

Continue

exit

are 3 lines, but when i use "WinGetText" , i sometimes get the result like this:

InstallationContinueExit

And i also cannot split it with "SplitString", cause there is no space between words.

Thanks for help

Edited by Orao

Share this post


Link to post
Share on other sites

Can you post a screenshot of the window?

When I try WinGetText I get all spaces and @CRLF.


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

#6 ·  Posted (edited)

My code is following:

sleep(3000)
Local $title = WinGetTitle("[active]", "")

Local $text = WinGetText("[active]" , "" )

Run("C:Program Files (x86)AutoIt3SciTEscite.exe")
sleep(2000)
send($text)

When i try to write the text to Scite then it puts all the text into same line, without spaces.post-64065-0-56628700-1329572419_thumb.p

When i try to write the same text to a notepad editor, then it works fine : post-64065-0-97256600-1329572428_thumb.p

Is there a way how i can write this text to Scite, but line by line, and can i choose to write just the first line (cause otherwise its too much text)??

thanks

Edited by Orao

Share this post


Link to post
Share on other sites

Is this a real life problem you need to solve or do you just play around and see how things work?


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

Why are you running the editor (SciTE) again?


- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Share this post


Link to post
Share on other sites

What i am trying to do is a script which will automatically get Title, Text and Mouse position of an active Window, each time when i launch it.

So i don't have to copy line by line from "Autoit Window info" , and put the code manually which takes a long time.

The same thing i could do with "au3recorder.exe", but as i said, "au3recorder.exe" sometimes doesn't work correctly (sometimes it just skips a certain window, and just collects the mouseclick position- without the: "_WinWaitActivate("Windows Tittle", "Window text")).

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