Bleu Posted August 14, 2006 Posted August 14, 2006 (edited) Hi My Problem is I want to write a chat message. You have to type in a text char by char and then press Enter to commit the Message. the sendKey Function sends the key to a specified window and is not important for my question. My first function works fine: Func writeHello() sendKey("{H}") sendKey("{e}") sendKey("{l}") sendKey("{l}") sendKey("{o}") sendKey("{ENTER}") EndFunc But I need more chat messages and I don't want to write for every single message a new function. I want a function that creates a chat message from the given argument. I got this code so far: ... chat("Hello") ... Func chat($text) For $i = 1 to stringlen($text) $i = $i + 1 sendKey("{H}") Next sendKey("{ENTER}") EndFunc I don' know how to parse the characters of the string to a key. I tried to do something with string.sub() but i didnt get far so I hope you have an idea how i can simply realize my idea or help me with the code. Greetings Bleu Edited August 14, 2006 by Bleu
CoePSX Posted August 14, 2006 Posted August 14, 2006 When using a For, you don't have to increase the varible's value. This way you'll be jumping 2 values instead of 1. There's a funtcion that splits a string into an array. It's StringSplit. ... chat("Hello") ... Func chat($text) $TempArray = StringSplit($text, "") ;Split on each chatacter For $i = 1 to $TempArray[0] Step 1 sendKey("{" & $TempArray[$i] & "}") Next sendKey("{ENTER}") EndFunc StringSplit return the number of items on $TempArray[0]. I assume you want to use {a} instead of a, so i put "{" and "}" before and after the current character. [quote name='Valik' post='301213' date='Jan 31 2007, 10:36 PM']You seem to have a habit of putting things in the wrong place. I feel sorry for any female you attempt to have sex with.[/quote][font="Lucida Sans Unicode"]╔══════════════════════════════╗║░░██░░░░░░░░██░░███░░░████░░░█║║░█░░█░░██░░█░░█░█░░█░█░░░░█░█░║║░█░░░░█░░█░████░███░░░██░░░█░░║║░█░░█░█░░█░█░░░░█░░░░░░░█░█░█░║║░░██░░░██░░░██░░█░░░░███░█░░░█║╚══════════════════════════════╝[/font]
omglol Posted August 14, 2006 Posted August 14, 2006 (edited) Func writeHello() Send("Hello") Send("{Enter}") EndFunc should work aswell right? edit: it'll do the work, hope it helps. Edited August 14, 2006 by omglol
CoePSX Posted August 14, 2006 Posted August 14, 2006 Yes. The {} are used for special keys like {ESC}, {Enter}, {Backspace} etc. If you want to use the Send command not interpreting this, just use Send("BlaBla" & @CR, 1) <-- The , 1 is send raw mode. Sending in raw mode ignores the special keys. Send("{Tab}", 1) Would send {Tab} instead of a tab character. [quote name='Valik' post='301213' date='Jan 31 2007, 10:36 PM']You seem to have a habit of putting things in the wrong place. I feel sorry for any female you attempt to have sex with.[/quote][font="Lucida Sans Unicode"]╔══════════════════════════════╗║░░██░░░░░░░░██░░███░░░████░░░█║║░█░░█░░██░░█░░█░█░░█░█░░░░█░█░║║░█░░░░█░░█░████░███░░░██░░░█░░║║░█░░█░█░░█░█░░░░█░░░░░░░█░█░█░║║░░██░░░██░░░██░░█░░░░███░█░░░█║╚══════════════════════════════╝[/font]
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