Jump to content
Sign in to follow this  
Kiti

Replacing letters in a text

Recommended Posts

Kiti

Hi!

I want a script to replace all letters from a specified box (from an instant messaging client (Yahoo Messenger)), so I'll talk in leet.

Y0|_| |<|\|0\/\/, 7|-|15 |<1|\||) 0f 57|_|ff. But how can I get the text I am typing and replace some letters?

Thank to all of you for your help!

Share this post


Link to post
Share on other sites
Kiti

and how can I get the text from that window?

Or it's better to create a GUI in which I enter text and it sends it in the specified window?

And can you give me an example, please? :) Because I'm programing in AutoIt for a few hours and it's a little hard for me to get it, at least now, at the beginning.

Share this post


Link to post
Share on other sites
Kiti

I've downloaded that yesterday, and walk through it all way to the end, so today I've start writing my own little scripts. (Although the second break-time game is not working and the Koda is not opening every time I click the picture :) )

It was very very helpful, and I've learned a lot from it. But I didn't saw anything about replacing, or sending keystrokes to a specified window (just to the active one).

Share this post


Link to post
Share on other sites
zorphnog

You're answering your own question...sort of. Just activate the window (hint: WinActivate) and replace text or send keystrokes.

Share this post


Link to post
Share on other sites
Kiti

Hmm... ok, but if the title is not always the same? Anyway, let's suppose I'll activate it myself, I used Window Info and I found that that box is called "YIMInputWindow1". And I've tried to Msgbox(title, YIMInputWindow1), but I get syntax error. Obviously, this is not the correct way of doing it. Please someone light me :)

Share this post


Link to post
Share on other sites
Kerros

your other best friend, and mine too, is the help file. I usually keep the help file open whenever I'm scripting, just to check syntax.

For your message box your missing a piece of information.

MsgBox (flag, "title", "text" [, timeout [, hwnd]] )

Place a 0 in your msgbox at the flag location. That should fix that error.

Edit: Typo

Edited by Kerros

Kerros===============================================================How to learn scripting: Figure out enough to be dangerous, then ask for assistance.

Share this post


Link to post
Share on other sites
Kiti

Ok, but know it thinks it's just a text, so I got a message with "YIMInputWindow1". How can I solve this problem?

But, anyway, let's suppose I'm entering the text directly, what's the exact method of replacing the characters? (an example would be much more than great:D)

Share this post


Link to post
Share on other sites
zackrspv

Ok, but know it thinks it's just a text, so I got a message with "YIMInputWindow1". How can I solve this problem?

But, anyway, let's suppose I'm entering the text directly, what's the exact method of replacing the characters? (an example would be much more than great:D)

I had fun playing around with a script that would automaticaly replace letters as you type them in:

#include<GUIConstantsEx.au3>
#include<Array.au3>
$back = ""
Dim $replace[5][2] = [["a", "z"], ["b", "y"], ["c", "x"], ["d", "w"], ["e", "v"]]
$form = GUICreate("Live Text", 400, 50)
$label = GUICtrlCreateLabel("Letters A - E will be replaced.", 0, 5)
$input = GUICtrlCreateInput("", 0, 20, 400, 25)
GUISetState()

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
            Exit
        Case Else
            $old = GUICtrlRead($input)
            If $back = $old Then
            Else
                $oldN = StringLeft($old, StringLen($old) - 1)
                $new = StringRight($old, 1)
                $index = _ArraySearch($replace, $new, 0, 0, 0, 0, 1, 0)
                ConsoleWrite($index & @CRLF)
                If $index = -1 Then
                Else
                    $newT = $oldN & $replace[$index][1]
                    GUICtrlSetData($input, $newT)
                EndIf
            EndIf
            $back = $old
    EndSwitch
WEnd

May not be what you wanted to do, but it was fun to do this.

Mind you this is using Autoit 3.2.12.0 The Array functions have changed quite a bit from v10, so if you don't have v12, chances are this may not work as expected :)

Updated: To do the l33t speak i you could juse this dim:

Dim $replace[26][2] = [["a", "/-\"], ["b", "8"], ["c", "<"], ["d", ">"], ["e", "3"], ["f", "/="], ["g", "6"], ["h", "/-/"], ["i", "1"], ["j", "_/"], ["k", "|<"], ["l", "|"], ["m", "|v|"], ["n", "/\/"], ["o", "()"], ["p", "|*"], ["q", "()_"], ["r", "|?"], ["s", "5"], ["t", "+"], ["u", "(_)"], ["v", "\/"], ["w", "vv"], ["x", "><"], ["y", "`/"], ["z", "%"]]

Updated2: The k wasn't working, it's fixed now :)

Note, that it is all ONE LINE, this forum will automatically break it up, but just put it on one line and you should be ok.

Should also note that the useage of those symbols is traditional l33t, from wiki's site lol if you want legible l33t then well, you'd have to recode the dim :)

Edited by zackrspv

-_-------__--_-_-____---_-_--_-__-__-_ ^^€ñ†®øÞÿ ë×阮§ wï†høµ† ƒë@®, wï†høµ† †ïmë, @ñd wï†høµ† @ †ïmïdï†ÿ ƒø® !ïƒë. €×阮 ñø†, bµ† ïñ§†ë@d wï†hïñ, ñ@ÿ, †h®øµghøµ† †hë 맧ëñ§ë øƒ !ïƒë.

Share this post


Link to post
Share on other sites
Kiti

Thank you very very much zackrspv !!

I made my own leet instead of the traditional one:

Dim $replace[26][2] = [["a", "4"], ["b", "|3"], ["c", "("], ["d", "|)"], ["e", "3"], ["f", "|="], ["g", "6"], ["h", "|-|"], ["i", "1"], ["j", "_|"], ["k", "|<"], ["l", "|"], ["m", "|v|"], ["n", "|\|"], ["o", "0"], ["p", "|*"], ["q", "q"], ["r", "|2"], ["s", "5"], ["t", "7"], ["u", "|_|"], ["v", "\/"], ["w", "vv"], ["x", "><"], ["y", "`/"], ["z", "2"]]

4nd 0n3 m0r3 51mpl3 4nd r34d48l3 0n3, r3pl4c1n6 0nly wh47 c4n 83 r3pl4c3d 8y num83r5.

So I am alternatively commenting two of these tree lines, but I was wondering how can I put a hotkey.

I know how:

HotKeySet("{ESC}", "Terminate")
Func Terminate()
    Exit 0
EndFunc

But how can I make a hotkey to specify which of the three replacing codes should it use? And how can I get the text from that box and use the send() function for example? I saw Ctrl+A doesn't work so it must be another internal way to get the text from there (eventually when I press another hotkey).

Thank you again for your code, it was marvelous. :)

Share this post


Link to post
Share on other sites
jvnorris

AS for obtaining the data to be translated. use ControlGetText it will pull all text info from a selected field in a control.

Once you have the data translate it.

Then use ControlSend to put it where it needs to be. Using the AU3info tool will help you get the control info you need for these functions.

A nicer way would flow like this.

(Hotey pressed)

Info box for text to translate

Translate text.

Translated version plced in messenger screen

Edited by jvnorris

Share this post


Link to post
Share on other sites
Kiti
Kiti
zackrspv

And how can I use hotkeys to choose which one of the three leet "alphabets" should it use?

Sorry, small c hange to my code hehe

HotKeySet("!^1", "_L33t1")
HotKeySet("!^2", "_L33t2")
HotKeySet("!^3", "_L33t3")

Dim $replace[26][2] = [["a", "4"], ["b", "|3"], ["c", "("], ["d", "|)"], ["e", "3"], ["f", "|="], ["g", "6"], ["h", "|-|"], ["i", "1"], ["j", "_|"], ["k", "|<"], ["l", "|"], ["m", "|v|"], ["n", "|\|"], ["o", "0"], ["p", "|*"], ["q", "q"], ["r", "|2"], ["s", "5"], ["t", "7"], ["u", "|_|"], ["v", "\/"], ["w", "vv"], ["x", "><"], ["y", "`/"], ["z", "2"]]

Func CreateL33t()
EndFunc

Func _L33t1()
    Dim $replace[26][2] = [["a", "4"], ["b", "|3"], ["c", "("], ["d", "|)"], ["e", "3"], ["f", "|="], ["g", "6"], ["h", "|-|"], ["i", "1"], ["j", "_|"], ["k", "|<"], ["l", "|"], ["m", "|v|"], ["n", "|\|"], ["o", "0"], ["p", "|*"], ["q", "q"], ["r", "|2"], ["s", "5"], ["t", "7"], ["u", "|_|"], ["v", "\/"], ["w", "vv"], ["x", "><"], ["y", "`/"], ["z", "2"]]
EndFunc

Func _L33t2()
    Dim $replace[26][2] = [["a", "4"], ["b", "|3"], ["c", "("], ["d", "|)"], ["e", "3"], ["f", "|="], ["g", "6"], ["h", "|-|"], ["i", "1"], ["j", "_|"], ["k", "|<"], ["l", "|"], ["m", "|v|"], ["n", "|\|"], ["o", "0"], ["p", "|*"], ["q", "q"], ["r", "|2"], ["s", "5"], ["t", "7"], ["u", "|_|"], ["v", "\/"], ["w", "vv"], ["x", "><"], ["y", "`/"], ["z", "2"]]
EndFunc

Func _L33t3()
    Dim $replace[26][2] = [["a", "4"], ["b", "|3"], ["c", "("], ["d", "|)"], ["e", "3"], ["f", "|="], ["g", "6"], ["h", "|-|"], ["i", "1"], ["j", "_|"], ["k", "|<"], ["l", "|"], ["m", "|v|"], ["n", "|\|"], ["o", "0"], ["p", "|*"], ["q", "q"], ["r", "|2"], ["s", "5"], ["t", "7"], ["u", "|_|"], ["v", "\/"], ["w", "vv"], ["x", "><"], ["y", "`/"], ["z", "2"]]
EndFunc

Note that's how you would use hotkeys to change what alphabet to use. The working function is where the translation would actually go, i'm sure you can figure that out :)


-_-------__--_-_-____---_-_--_-__-__-_ ^^€ñ†®øÞÿ ë×阮§ wï†høµ† ƒë@®, wï†høµ† †ïmë, @ñd wï†høµ† @ †ïmïdï†ÿ ƒø® !ïƒë. €×阮 ñø†, bµ† ïñ§†ë@d wï†hïñ, ñ@ÿ, †h®øµghøµ† †hë 맧ëñ§ë øƒ !ïƒë.

Share this post


Link to post
Share on other sites
Kiti
Kiti

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  

×