Jump to content

Find and replace all instances of text in a window


mynci
 Share

Recommended Posts

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

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

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

Link to comment
Share on other sites

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
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...