liam0002 Posted October 10, 2021 Share Posted October 10, 2021 Hi, i created a simple script that send's a text when you press F1. The problem is there is html code inside and its interfering with the Autoit code itself. How do i make it so Autoit ignores the code and just pastes the text like a normal text? Thanks HotKeySet("{F1}", "SendMe") While 1 Sleep(100) WEnd Func SendMe() Send("- Sehr flexibel") Send("{Enter}") Send("- Rundum Schutz") Send("{Enter}") Send("- Rückseite druckbar") Send("{Enter}") Send("<p style="text-align: left;"><a href="https://www.anchorcase.de/soft-case/" target="_blank" rel="noopener">Mehr Infos zum Produkt</a></p>") EndFunc Link to comment Share on other sites More sharing options...
Solution AlessandroAvolio Posted October 10, 2021 Solution Share Posted October 10, 2021 https://www.autoitscript.com/autoit3/docs/intro/lang_datatypes.htm Quote Strings Strings are enclosed in double-quotes like "this". If you want a string to actually contain a double-quote use it twice like: "here is a ""double-quote"" - ok?" You can also use single-quotes like 'this' and 'here is a ' 'single-quote' ' - ok?' You can mix quote types to make for easier working and to avoid having to double-up your quotes to get what you want. For example if you want to use a lot of double-quotes in your strings then you should use single-quotes for declaring them: 'This "sentence" contains "lots" of "double-quotes" does it not?' is much simpler than: "This ""sentence"" contains ""lots"" of ""double-quotes"" does it not?" liam0002 1 Link to comment Share on other sites More sharing options...
Danp2 Posted October 10, 2021 Share Posted October 10, 2021 Since the string contains double quotes, you can wrap it in single quotes instead. liam0002 1 Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
liam0002 Posted October 10, 2021 Author Share Posted October 10, 2021 Cool, that worked, thanks HotKeySet("{F1}", "SendMe") While 1 Sleep(100) WEnd Func SendMe() Send("- Sehr flexibel") Send("{Enter}") Send("- Rundum Schutz") Send("{Enter}") Send("- Rückseite druckbar") Send("{Enter}") Send('"<p style="text-align: left;"><a href="https://www.anchorcase.de/soft-case/" target="_blank" rel="noopener">Mehr Infos zum Produkt</a></p>"') EndFunc Link to comment Share on other sites More sharing options...
liam0002 Posted October 10, 2021 Author Share Posted October 10, 2021 Is it possible to send/paste the text instantly ? Without the text effect? https://streamable.com/brjlav Thanks Link to comment Share on other sites More sharing options...
Danp2 Posted October 10, 2021 Share Posted October 10, 2021 Place the text on the clipboard and then send Ctrl+V to paste. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
AlessandroAvolio Posted October 10, 2021 Share Posted October 10, 2021 Quote Opt("SendKeyDelay",...) alters the the length of the brief pause in between sent keystrokes. https://www.autoitscript.com/autoit3/docs/functions/Send.htm Link to comment Share on other sites More sharing options...
Musashi Posted October 10, 2021 Share Posted October 10, 2021 Regarding Opt("SendKeyDelay, ...) " : Even with value 0 there is still a bit of a delay (at least on my system). The suggestion by @Danp2 ("Place the text on the clipboard and then send Ctrl+V to paste.") works without delay. Example : Opt("SendKeyDelay", 0) Local $sText = "Write text into line 01 of the editor window" & @CRLF & _ "Write text into line 02 of the editor window" & @CRLF & _ "Write text into line 03 of the editor window" & @CRLF & _ "==> wait 2 seconds" & @CRLF ; To visiualize, run Notepad with the window maximized. Local $iPID = Run("notepad.exe", "", @SW_SHOWMAXIMIZED) WinWait("[CLASS:Notepad]", "", 10) ; 1 . : Send($sText) Sleep(2000) ; Clear Window : Send("^a") Sleep(500) Send("{DEL}") Sleep(1000) ; 2. Retrieves text from the clipboard ClipPut($sText) Send("^v") ; paste via CTRL+V Sleep(2000) ; Close the Notepad process using the PID returned by Run. ProcessClose($iPID) ConsoleWrite("Close the Notepad process" & @CRLF) "In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move." Link to comment Share on other sites More sharing options...
AlessandroAvolio Posted October 10, 2021 Share Posted October 10, 2021 12 hours ago, liam0002 said: Is it possible to send/paste the text instantly ? Without the text effect? https://streamable.com/brjlav Thanks @Musashi that is the solution if you want to use Send. @Danp2 has already answered on how to paste from the clipboard Link to comment Share on other sites More sharing options...
liam0002 Posted October 11, 2021 Author Share Posted October 11, 2021 (edited) The only solution for this is to make Autoit write the text and then copy and paste it ? There is no option to paste it right away without the text animation? For example this is done with macro tool: https://streamable.com/eccofk The only problem is it does only support one line of text per hotkey, so i dont want to press 4 keys after another. Everything should be pasted with just one click mouse click. Thanks Edited October 11, 2021 by liam0002 Link to comment Share on other sites More sharing options...
AlessandroAvolio Posted October 11, 2021 Share Posted October 11, 2021 1 hour ago, liam0002 said: The only solution for this is to make Autoit write the text and then copy and paste it ? There is no option to paste it right away without the text animation? For example this is done with macro tool: https://streamable.com/eccofk The only problem is it does only support one line of text per hotkey, so i dont want to press 4 keys after another. Everything should be pasted with just one click mouse click. Thanks You can with ClipPut() and Send("^v") https://www.autoitscript.com/autoit3/docs/functions/ClipPut.htm Main() Func Main() ClipPut("123123123123123123123123123123123123123123" _ & "123123123123123123123123123123123123123123" _ & "123123123123123123123123123123123123123123" _ & "123123123123123123123123123123123123123123" _ & "123123123123123123123123123123123123123123" _ & "123123123123123123123123123123123123123123" _ & "123123123123123123123123123123123123123123" _ & "123123123123123123123123123123123123123123" _ & "123123123123123123123123123123123123123123" _ & "123123123123123123123123123123123123123123" _ & "123123123123123123123123123123123123123123" _ & "123123123123123123123123123123123123123123" _ & "123123123123123123123123123123123123123123" _ & "123123123123123123123123123123123123123123" _ & "123123123123123123123123123123123123123123" _ & "123123123123123123123123123123123123123123" _ & "123123123123123123123123123123123123123123" _ & "123123123123123123123123123123123123123123" _ & "123123123123123123123123123123123123123123" _ & "123123123123123123123123123123123123123123" _ & "123123123123123123123123123123123123123123" _ & "123123123123123123123123123123123123123123" _ & "123123123123123123123123123123123123123123") Send("^v") EndFunc Link to comment Share on other sites More sharing options...
Musashi Posted October 11, 2021 Share Posted October 11, 2021 4 minutes ago, AlessandroAvolio said: You can with ClipPut() and Send("^v") Just out of curiosity (maybe I'm missing something) : How does this differ from my code snippet ? [...] ; 2. Retrieves text from the clipboard ClipPut($sText) Send("^v") ; paste via CTRL+V [...] "In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move." Link to comment Share on other sites More sharing options...
AlessandroAvolio Posted October 11, 2021 Share Posted October 11, 2021 (edited) On 10/12/2021 at 12:03 AM, Musashi said: Just out of curiosity (maybe I'm missing something) : How does this differ from my code snippet ? [...] ; 2. Retrieves text from the clipboard ClipPut($sText) Send("^v") ; paste via CTRL+V [...] that's my answer Edited December 14, 2021 by AlessandroAvolio Link to comment Share on other sites More sharing options...
JockoDundee Posted October 19, 2021 Share Posted October 19, 2021 On 10/11/2021 at 3:06 PM, AlessandroAvolio said: Let your guard down, there is no reason, that's my answer Don’t take @Musashi’s reticence to indicate anything besides his limitless tolerance for overtly fatuous responses. Musashi 1 Code hard, but don’t hard code... Link to comment Share on other sites More sharing options...
Zedna Posted October 19, 2021 Share Posted October 19, 2021 (edited) If possible then you can use ControlSetText() instead of Send() to avoid "animation effects". - as window title use "[active]" for actual active window - as ControlID use empty string to set text of focused control inside target window ControlSetText('[active]','','','my text to send') Edited October 19, 2021 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search 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