Jump to content

How to get Tittle and Text of an actieve window?


Orao
 Share

Recommended Posts

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)?

Link to comment
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

Link to comment
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.

Link to comment
Share on other sites

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
Link to comment
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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

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
Link to comment
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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
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")).

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...