Sign in to follow this  
Followers 0
mynci

Find and replace all instances of text in a window

5 posts in this topic

Hi,

i havent been able to find anything through searching, i hope that this is possible.

basically i have a nasty piece of software which has a kind of spread sheet object in it, i cant see any way of addressing the cells individually (although if this is wrong then please let me know).

therfore i would like to replace all occurances of one string in all of the cells on the page with another string. this will allow me to automate the use of this horrid piece of software and speed up a mundane task no end.

i can see no way of addressing the cells (the active window info doesnt seem to offer any unique handle to the cells), however the visible window text does change when the text is selected. so is it possible to do some sort of search and replace on all the window text?

is this possible? is there a better way? any more info needed, then just let me know.

regards

Mynci

Share this post


Link to post
Share on other sites



It might be an excel object, in which case you could use COM to interact with the cells. (Search the forum for examples)

Do any classes show up in the info window?

Please run this code and post the output:

MsgBox(0, "Classes", WinGetClassList("Window Title Goes Here", ""))

[font="Tahoma"]"Tougher than the toughies and smarter than the smarties"[/font]

Share this post


Link to post
Share on other sites

the objects are:

toolbarwndclass

toolbarwindow32

spr32x30_spreadsheet

ScrollBar

ScrollBar

StatusBarWndClass

i have managed to write a bit of a botcht to get round this, but its not ideal. i would be very interested to hear of any better solutions though.

many thanks.

Share this post


Link to post
Share on other sites

tell me what resolution you use (windows resolution) the text you want to find, the text you want to change it into, and what text editing program you use... and ill try to put something together...

if you use notepad this will be VERY easy, as i've done it before with no problem at all

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Here's one for notepad, it's actualy quite simple and easy to configure....

NPTR.au3

; ----------------------------------------------------------------------------
;
; Notepad Text Replacer
; Author:        TK_Incorperate <TK_Incorperate@yahoo.com>
;
; Script Function:
;   Replaces the character(s) in witch you chose, with other character(s) that you chose in notepad
;
; ----------------------------------------------------------------------------


WinActivate("###### - Notepad", "");Replace the ###### with your file name



HotKeySet("q", "Terminate");Completely stops replacing by pressing Q
HotKeySet("w", "Pause");Pauses the replacing untill you press W again
dim $Paused = 0



While 1
    TrayTip("Currently", "Replacing", 10)
        Send("{ALT}{RIGHT}{DOWN}f")
        Send("####");Replace the #### with the text you wish to find
        Send("{ENTER}{ESC}")
        Send("####");Replace the #### with the text you wish to replace the first text with
            Sleep(3000);I perfer keeping this at 3 seconds, but you can change to your likings
WEnd



Func Terminate()
    Exit 0
EndFunc



Func Pause()
    $Paused = NOT $Paused
    HotKeySet("w", "UnPause")
    TrayTip("Currently", "Paused", 10)
    While $Paused
    TrayTip("Currently", "Paused", 10)
    sleep(100)
    WEnd
EndFunc



Func UnPause()
    $Paused = NOT $Paused
    HotKeySet("w", "Pause")
EndFunc
Edited by TK_Incorperate

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