Nixcalo wrote:As a little update, Xtra solution does not work 100% of the time. I would say about 90%, which is way greater that the other solutions and it's definitely an improvement. Sometimes it does not work and what it does is delete what was selected, without replacing it with anything... but a great improvement nonetheless and with this success rate, script is a solution rather than a hindrance. THANK YOU! (Perhaps I have to add some "sleep" somewhere.."
sadly you never got around to answer guest3456
guest3456 wrote:can you state what exactly you are doing when it fails? what app are you using? what keys are you pressing? are you running the ^u script standalone or as part of a larger script?
I will point out
ClipWait wrote:Waits until the clipboard contains data...
Aka you have to give it the right conditions to work with, seen from your use case.
One example is if you wish to check that a copy command has worked, you can
empty the clipboard and use clipwait, as that waits for it to contain data at some point, by using the timeout param you can make sure it acts even if no data comes to the clipboard within a given timeframe.
but the second ClipWait in the code you find to be working 90% of the time, really does nothing as the clipboard at this point is not empty so the clipwait commands condition will always be true...
I'll post yet one more example of the code
![Smile :)](./images/smilies/icon_e_smile.gif)
yeah
Code: Select all
^u:: ; ctrl+u
; Making sure keys are up before continuing
KeyWait, Ctrl
KeyWait, u
; Put a blank string on the clipboard to clear it (for clipwait to work)
clipboard:=""
; Send the keys that tells the program to issue a cut to clipboard
Send, {Ctrl Down}x{Ctrl Up}
; wait for the clipboard to contain data (2 second wait before continuing on and Errorlevel is set to one)
ClipWait, 2
if (ErrorLevel) ; two seconds passed without the clipboard containing data
return ; so end hotkey routine execution, the cut may have happened but no paste will be done
; grab the data on the clipboard and store it in a variable we control
Variable_holding_the_string_from_the_clipboard := Clipboard
; use autohotkey functions to interact with the data in our own variables (upping a string in this case)
Variable_holding_the_string_from_the_clipboard_upped := Format("{:U}", Variable_holding_the_string_from_the_clipboard)
; putting the now upped string back on the clipboard
Clipboard := Variable_holding_the_string_from_the_clipboard_upped
; Send the keys that tells the program to issue a paste from the clipboard
Send, {Ctrl Down}v{Ctrl Up}
return ; end