Orao Posted February 16, 2012 Share Posted February 16, 2012 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 More sharing options...
Xenobiologist Posted February 16, 2012 Share Posted February 16, 2012 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 More sharing options...
somdcomputerguy Posted February 16, 2012 Share Posted February 16, 2012 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 More sharing options...
Orao Posted February 18, 2012 Author Share Posted February 18, 2012 (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 withWinGetText("[active]", "")Then i get all the text lines together, and there is no space between the lines:for example:InstallationContinueexitare 3 lines, but when i use "WinGetText" , i sometimes get the result like this:InstallationContinueExitAnd i also cannot split it with "SplitString", cause there is no space between words.Thanks for help Edited February 18, 2012 by Orao Link to comment Share on other sites More sharing options...
water Posted February 18, 2012 Share Posted February 18, 2012 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 - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
Orao Posted February 18, 2012 Author Share Posted February 18, 2012 (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. When i try to write the same text to a notepad editor, then it works fine : 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 February 18, 2012 by Orao Link to comment Share on other sites More sharing options...
water Posted February 18, 2012 Share Posted February 18, 2012 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 - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
somdcomputerguy Posted February 19, 2012 Share Posted February 19, 2012 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. Link to comment Share on other sites More sharing options...
Orao Posted February 19, 2012 Author Share Posted February 19, 2012 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now