cag8f Posted June 20, 2018 Share Posted June 20, 2018 Hi all. I want to create a simple keyboard shortcut that automatically pastes a small amount of custom text. But when I execute the assigned shortcut, nothing occurs. Specifically, here's what I did. I created an AutoIt script which contains one line: Send("my custom text"); I then compiled this script into an EXE, sent it to my desktop as a shortcut, and assigned a keyboard shortcut to that shortcut (ctrl + alt + q). But when I tested it, nothing happened. Specifically, I opened Notepad then executed the keyboard shortcut. After about 1-2 seconds, the Notepad window deselected, then nothing else happened. Thoughts on what I'm doing wrong? Thanks in advance. Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted June 20, 2018 Moderators Share Posted June 20, 2018 @cag8f why not just use HotKeySet, and run the compiled executable as a try app? This works just fine for me: HotKeySet("{F11}", "SendMe") While 1 Sleep(100) WEnd Func SendMe() Send("my custom text") EndFunc Fin 1 "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
careca Posted June 20, 2018 Share Posted June 20, 2018 (edited) When you start something by that method, you lose focus on the active window, i couldn't find a workaround that. Maybe, in theory, you could retrieve the Z order of the windows and activate the higher one before the send. Try: MouseClick("primary") Send("my custom text") Not elegant, but worked here, just have to keep the mouse in the window you want to paste. Edited June 20, 2018 by careca Spoiler Renamer - Rename files and folders, remove portions of text from the filename etc. GPO Tool - Export/Import Group policy settings. MirrorDir - Synchronize/Backup/Mirror Folders BeatsPlayer - Music player. Params Tool - Right click an exe to see it's parameters or execute them. String Trigger - Triggers pasting text or applications or internet links on specific strings. Inconspicuous - Hide files in plain sight, not fully encrypted. Regedit Control - Registry browsing history, quickly jump into any saved key. Time4Shutdown - Write the time for shutdown in minutes. Power Profiles Tool - Set a profile as active, delete, duplicate, export and import. Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes. NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s. IUIAutomation - Topic with framework and examples Au3Record.exe Link to comment Share on other sites More sharing options...
cag8f Posted June 20, 2018 Author Share Posted June 20, 2018 @JLogan3o13 Thanks for that. But what do you mean by "run the compiled executable as a try app?" @careca OK thanks, that worked. It's unfortunately a *tad* slow. The text I want to insert is fairly short (~25 characters). So I can type it relatively quickly--as quick as the keyboard shortcut inserts it. I was hoping a shortcut would be able to do so much faster. Is there perhaps some setting or parameter I'm missing? Link to comment Share on other sites More sharing options...
pixelsearch Posted June 20, 2018 Share Posted June 20, 2018 @cag8f : if you want the text to be written really fast, you have to change 2 options, as shown in this code : Opt("SendKeyDelay", 0) ; 0 removes completely the delay Opt("SendKeyDownDelay", 0) ; 0 removes completely the delay HotKeySet("{F11}", "SendMe") While 1 Sleep(100) WEnd Func SendMe() HotKeySet("{F11}") ; deactivate the hotkey in case the user presses it too long Send("my custom text") HotKeySet("{F11}", "SendMe") ; reactivate it EndFunc I tested it with Send() of 1000 characters, it took 2 seconds on my antique PC, then compared these 1000 characters to the originals, there were exactly the same. JLogan3o13 means that you have to double clic on the .exe, then its icon shows in the Systray and the program runs constantly in the background (because of the While WEnd loop that will never end) so you will able to press the F11 key in any window you like. When you're done, right clic on the systray icon, choose "exit" and the program will end. Good luck. Link to comment Share on other sites More sharing options...
cag8f Posted June 20, 2018 Author Share Posted June 20, 2018 @pixelsearch OK thanks very much for all that. I gave your code a try, and it worked just as you and @JLogan3o13 described. I have a couple follow-up questions: >> When you're done, right clic on the systray icon, choose "exit" and the program will end. Is there an actual need/benefit to doing this? I'd prefer it if I could simply shut down Windows. I gave it a test, and Windows shut down without complaining. But is this disadvantageous for any reason? Do you see any issue with placing the EXE in my startup folder, so I don't have to manually run it every time? Thanks! Link to comment Share on other sites More sharing options...
careca Posted June 20, 2018 Share Posted June 20, 2018 No problem, windows will close all processes. Yes you can put it in startup. I thought you didn't want another program running in background. Did you take a look at the programs that paste text in the download section? Instead of just one line, you could have multiple shortcuts and lines. Not trying to promote my program at all, just trying to show you what's available. Spoiler Renamer - Rename files and folders, remove portions of text from the filename etc. GPO Tool - Export/Import Group policy settings. MirrorDir - Synchronize/Backup/Mirror Folders BeatsPlayer - Music player. Params Tool - Right click an exe to see it's parameters or execute them. String Trigger - Triggers pasting text or applications or internet links on specific strings. Inconspicuous - Hide files in plain sight, not fully encrypted. Regedit Control - Registry browsing history, quickly jump into any saved key. Time4Shutdown - Write the time for shutdown in minutes. Power Profiles Tool - Set a profile as active, delete, duplicate, export and import. Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes. NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s. IUIAutomation - Topic with framework and examples Au3Record.exe Link to comment Share on other sites More sharing options...
cag8f Posted June 21, 2018 Author Share Posted June 21, 2018 (edited) @careca >> I thought you didn't want another program running in background. DId I say that? I don't recall saying that. If so, I didn't mean it. Another program in the background should be OK in this case. >> Did you take a look at the programs that paste text in the download section? No I didn't. Where are they? Can you send a link to those programs. >> Instead of just one line, you could have multiple shortcuts and lines. This actually sounds like something I might want. Edited June 23, 2018 by cag8f Link to comment Share on other sites More sharing options...
ViciousXUSMC Posted June 21, 2018 Share Posted June 21, 2018 JLogans answer is pretty much the standard for how to do this. The other thing I like ALOT so that I do not need to remember obscure hotkeys is HotStrings This lets you just come up with a word phrase. As an IT guy say I had a big block of text I send all the time as a generic reply to resetting a password. I can set a string like ";passwordreset" and type that and have it replaced with my block o' text Strings can be short and easy to remember. #Include <hotstring.au3> HotStringSet(";passwordreset", "_resetpassword") While 1 Sleep(10) WEnd Func _resetpassword() Send("{Backspace 14}Your password has been reset to _____ please login within the next 24 hours to set a new password or your account will get locked again and you will need to put a new ticket in for a new password reset request") EndFunc Link to comment Share on other sites More sharing options...
cag8f Posted June 23, 2018 Author Share Posted June 23, 2018 @ViciousXUSMC OK thanks for that. I can't think of any uses for hotstrings now, but I'll keep it in-mind. Link to comment Share on other sites More sharing options...
careca Posted June 23, 2018 Share Posted June 23, 2018 A similar take on that. Spoiler Renamer - Rename files and folders, remove portions of text from the filename etc. GPO Tool - Export/Import Group policy settings. MirrorDir - Synchronize/Backup/Mirror Folders BeatsPlayer - Music player. Params Tool - Right click an exe to see it's parameters or execute them. String Trigger - Triggers pasting text or applications or internet links on specific strings. Inconspicuous - Hide files in plain sight, not fully encrypted. Regedit Control - Registry browsing history, quickly jump into any saved key. Time4Shutdown - Write the time for shutdown in minutes. Power Profiles Tool - Set a profile as active, delete, duplicate, export and import. Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes. NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s. IUIAutomation - Topic with framework and examples Au3Record.exe Link to comment Share on other sites More sharing options...
cag8f Posted June 23, 2018 Author Share Posted June 23, 2018 @careca Got it, thanks--I"ll look into it. 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