OKILI Posted March 18, 2009 Share Posted March 18, 2009 Hello, I'm new to AutoIt and want to create program, which will replace some symbols in my selection by the other ones. For example I select the text "Hello World", then I will run the script and it will replace all "l"-s by "#" and all "o" by "@" so my selection will be changed to "He##@ W@r#d". As I have said I am newbie and have no idea how to do that... Hope that it is possible and it is not hard. Any helpful comments are appreciated. Thanks in advance... Link to comment Share on other sites More sharing options...
Drew Posted March 18, 2009 Share Posted March 18, 2009 There are multiple ways of course, however an easy way since your new ... ( However very time consuming depending on how many letters your wanted to change.... ) Set a hotkey for each letter and have it Send the symbol you want. Like I said... There are many ways to go about this but thats by far the simplest. ( And is definitely the most time consuming. ) Link to comment Share on other sites More sharing options...
OKILI Posted March 18, 2009 Author Share Posted March 18, 2009 There are multiple ways of course, however an easy way since your new ... ( However very time consuming depending on how many letters your wanted to change.... )Set a hotkey for each letter and have it Send the symbol you want. Like I said... There are many ways to go about this but thats by far the simplest. ( And is definitely the most time consuming. )First of all thanks for the answer,but I do not know even any of these multiple ways. Probably the Send command is the only thing which I know for this time, but how to set hotkey for each letter I do not know Can anybody post a sample code how this could be done?Or please post any way by which the target can be reached... Link to comment Share on other sites More sharing options...
Authenticity Posted March 18, 2009 Share Posted March 18, 2009 HotKeySet('{ESC}', '_EXIT') ; To exit HotKeySet('^r', 'SearchAndReplace') ; Ctrl+r Run('notepad') WinWaitActive('Untitled') Send('Hello world') While 1 Sleep(20) WEnd ; Requires text selected preior to calling this one Func SearchAndReplace() Local $Clip;, $OldClip = ClipGet() ; Uncomment to restore previous clipboard ; content. Send('^c') $Clip = ClipGet() If $Clip == "" Then Return $Clip = StringReplace($Clip, 'l', '#') ; Case-insensitive $Clip = StringRegExpReplace($Clip, 'o', '@') ; Same MsgBox(0x40, 'Modified text', $Clip) ;ClipPut($OldClip) ; Uncomment to restore previous clipboard ; content. EndFunc Func _EXIT() Exit EndFunc Then, it's your creative mind of how to and what to... ;] Link to comment Share on other sites More sharing options...
OKILI Posted March 19, 2009 Author Share Posted March 19, 2009 Authenticity,Thank you very much, this one is almost exactly what I wanted. That is how the final version looks like:HotKeySet('{ESC}', '_EXIT'); To exit HotKeySet('^r', 'SearchAndReplace'); Ctrl+r While 1 Sleep(20) WEnd Func SearchAndReplace() Local $Clip Send('^c') $Clip = ClipGet() If $Clip == "" Then Return $Clip = StringReplace($Clip, 'l', '#'); Case-insensitive $Clip = StringRegExpReplace($Clip, 'o', '@'); Same Send($Clip) EndFunc Func _EXIT() Exit EndFuncI only changed the "MsgBox(0x40, 'Modified text', $Clip)" to "Send($Clip)" to replace the selection. So everything works well for English texts.But another problem is that when I replaced the # and @ symbols by unicode keys ("ლ" and "ო"), they did not appear correctly, even when I set the encoding to UTF-8. (This version of AutoIt already has unicode support, but for this one it didn't work)However the code was very useful for me and probably this unicode problem will be fixed in newer versions.The purpose of the "program" I want to make is that sometimes, when I erroneously type something with Georgian letters (unicode) instead of English ones, I want to just select what I have typed and convert it to English letters and vice-versa. Link to comment Share on other sites More sharing options...
Authenticity Posted March 19, 2009 Share Posted March 19, 2009 You can put the unicode string in the clipboard and send "^v" instead of the string. 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