I use ::ATB::All The Best
and IT works great if I type out ATB. But if I paste ATB and hit enter it does not trigger the hotstring
Why does my hotstring not work when I copy paste Topic is solved
Re: Why does my hotstring not work when I copy paste
Because the way the hotstring triggers is by basically keylogging you. Pasting does not trip the keylogger; it only sees the Ctrl and V keys, or that you right clicked and made a menu selection.
However... if you simulate the typing, and if you make sure that your simulated typing can trigger keys, it should work. See this recent thread on hotstrings which is related to your question: https://autohotkey.com/boards/viewtopic ... 09#p181009
This code worked for me; I copied the ATB to my clipboard with a manual Ctrl+C, pasted it, and then hit the Space key (Enter should work fine too) to trigger the replacement. If an ending character (see #Hotstring EndChars) is included after the ATB on the clipboard, it'll automatically trigger the hotstring for you.
This does replace your native pasting functionality and I expect would prevent pasting images. So you may like to change your hotkey to something like ^+v (Ctrl+Shift+v) or do !v (Alt+v).
However... if you simulate the typing, and if you make sure that your simulated typing can trigger keys, it should work. See this recent thread on hotstrings which is related to your question: https://autohotkey.com/boards/viewtopic ... 09#p181009
This code worked for me; I copied the ATB to my clipboard with a manual Ctrl+C, pasted it, and then hit the Space key (Enter should work fine too) to trigger the replacement. If an ending character (see #Hotstring EndChars) is included after the ATB on the clipboard, it'll automatically trigger the hotstring for you.
Code: Select all
::ATB::All The Best
^v::
SendLevel, 2
SendRaw %clipboard%
return
Re: Why does my hotstring not work when I copy paste Topic is solved
this code does not work when you copy and paste using the mouseExaskryz wrote:Because the way the hotstring triggers is by basically keylogging you. Pasting does not trip the keylogger; it only sees the Ctrl and V keys, or that you right clicked and made a menu selection.
However... if you simulate the typing, and if you make sure that your simulated typing can trigger keys, it should work. See this recent thread on hotstrings which is related to your question: https://autohotkey.com/boards/viewtopic ... 09#p181009
This code worked for me; I copied the ATB to my clipboard with a manual Ctrl+C, pasted it, and then hit the Space key (Enter should work fine too) to trigger the replacement. If an ending character (see #Hotstring EndChars) is included after the ATB on the clipboard, it'll automatically trigger the hotstring for you.
This does replace your native pasting functionality and I expect would prevent pasting images. So you may like to change your hotkey to something like ^+v (Ctrl+Shift+v) or do !v (Alt+v).Code: Select all
::ATB::All The Best ^v:: SendLevel, 2 SendRaw %clipboard% return
Re: Why does my hotstring not work when I copy paste
this takes the text that is currently highlighted and if its an abbreviation thats in your hotstring file then it will convert it to the replacement.
everything after "clipWait" sounds like it would work for your siutation
you will have to modify it depending on how you have your hotstrings set up. its best of they are in a file on their own so it doesnt have to loop through too much text
then put the fileread part in your auto-execute section so you dont have to read it every time you run the above code
everything after "clipWait" sounds like it would work for your siutation
Code: Select all
clipboard_all := clipboardAll
clipboard := ""
send ^{c}
clipWait, 0.3
selected := clipboard
loop, parse, hotstring_list, `n, `r
{
if !inStr(a_loopField, "::")
continue
split := strSplit(a_loopField, ":")
if (split[3] = selected) ; split3 = abbreviation
{
clipboard := split[5] ; split5 = replacement text
send ^{v}
sleep 200
break
}
}
clipboard := clipboard_all
then put the fileread part in your auto-execute section so you dont have to read it every time you run the above code
Code: Select all
fileRead, hotstring_list, C:\file_that_contains_your_hostrings.ahk
Re: Why does my hotstring not work when I copy paste
If AHK knows a way to detect when you are trying to paste and intercept it, or if AHK has a way to know what item in the context menu you've selected, you could code that. The only thing I can imagine is doing this:Hildagard K wrote:this code does not work when you copy and paste using the mouseExaskryz wrote:Because the way the hotstring triggers is by basically keylogging you. Pasting does not trip the keylogger; it only sees the Ctrl and V keys, or that you right clicked and made a menu selection.
However... if you simulate the typing, and if you make sure that your simulated typing can trigger keys, it should work. See this recent thread on hotstrings which is related to your question: https://autohotkey.com/boards/viewtopic ... 09#p181009
This code worked for me; I copied the ATB to my clipboard with a manual Ctrl+C, pasted it, and then hit the Space key (Enter should work fine too) to trigger the replacement. If an ending character (see #Hotstring EndChars) is included after the ATB on the clipboard, it'll automatically trigger the hotstring for you.
This does replace your native pasting functionality and I expect would prevent pasting images. So you may like to change your hotkey to something like ^+v (Ctrl+Shift+v) or do !v (Alt+v).Code: Select all
::ATB::All The Best ^v:: SendLevel, 2 SendRaw %clipboard% return
Code: Select all
~RButton::
MouseGetPos, StartX, StartY
KeyWait, LButton, D
MouseGetPos, EndX, EndY
If (EndX-StartX < 100) ; set the 100 to the width in pixels of your right click menu
&& (EndY-StartY > 150) && (EndY-StartY < 200) ; set a "top of item" and "bottom of item" boundary, like if it's 175 pixels from the top of the menu to select "paste", you'd want the range to include 175
; However, if you click toward the top or bottom of the screen these coordinates change, so you need to ranges. Same to clicking on the right or left of your screen
{
Send {Esc} ; to cancel the menu
SendLevel, 2
SendRaw %clipboard%
}
else
Click
return