berban / Clip

Clip() - Send and Retrieve Text using the Clipboard
22 stars 8 forks source link

Using the function results in Ctrl+V functionality to be completely lost #1

Open Gewerd-Strauss opened 3 years ago

Gewerd-Strauss commented 3 years ago

Hello,

in search of an actually working method of pasting variables contents (because my PC decided it just doesn't want to accept code that has been working flawlessly the last six months), I've stumbled upon this function. It is neat, does what I expect and want it to do, very reliably - to be fair, my previous solution did also never not work till today, but yeah.

However, it has one problem for me that makes this function absolutely unusable for me, and I strongly suspect it to be a bug. If I use this in any script, and execute the lines, I can no longer use Ctrl+V to paste my clipboard. It just doesn't happen. I then need to restart the script containing the used Clip()-instance, and can then use Ctrl+V again - until the next time it is triggered. This does not happen if the section of code containing the function call is not triggered. In that case, I can happily use Ctr+V.

I took a look at the function, but couldn't find anything that immediately came to mind. I have attached the code I am using to trigger the function. I did test it with a simple hotkey and within an autorun section, the same bug was the result

`Gui, New,, Comment Creator Gui, add, Text, x025 y015, Comment will be inserted at position of triggerstring gui, add, Edit, r50 vVComment w1000 WantTab, Date: %A_DD% %A_MMMM% %A_YYYY% %A_Hour%:%A_Min%:%A_Sec%:``n gui, add, Button, gSubmitText, Insert Comment gui, show if WinActive("Comment Creator") { sleep, 20 SendInput, {End} } return

If WinActive("Comment Creator")

^Enter::ControlClick Insert Comment, Comment Creator ; AHK Studio: Comment Creator || Submit Text

If

SubmitText: gui, submit gui, destroy CommentStruct=/*n%VComment%`n*/ ;fClip(CommentStruct) ;mf_PasteVar(CommentStruct) fClip(CommentStruct) return

Gewerd-Strauss commented 3 years ago

Hello,

in search of an actually working method of pasting variables contents (because my PC decided it just doesn't want to accept code that has been working flawlessly the last six months), I've stumbled upon this function. It is neat, does what I expect and want it to do, very reliably - to be fair, my previous solution did also never not work till today, but yeah.

However, it has one problem for me that makes this function absolutely unusable for me, and I strongly suspect it to be a bug. If I use this in any script, and execute the lines, I can no longer use Ctrl+V to paste my clipboard. It just doesn't happen. I then need to restart the script containing the used Clip()-instance, and can then use Ctrl+V again - until the next time it is triggered. This does not happen if the section of code containing the function call is not triggered. In that case, I can happily use Ctr+V.

I took a look at the function, but couldn't find anything that immediately came to mind. I have attached the code I am using to trigger the function. I did test it with a simple hotkey and within an autorun section, the same bug was the result

Gui, New,, Comment Creator Gui, add, Text, x025 y015, Comment will be inserted at position of triggerstring gui, add, Edit, r50 vVComment w1000 WantTab, Date: %A_DD% %A_MMMM% %A_YYYY% %A_Hour%:%A_Min%:%A_Sec%:n gui, add, Button, gSubmitText, Insert Comment gui, show if WinActive("Comment Creator") { sleep, 20 SendInput, {End} } return #If WinActive("Comment Creator") ^Enter::ControlClick Insert Comment, Comment Creator ; AHK Studio: Comment Creator || Submit Text #If SubmitText: gui, submit gui, destroy CommentStruct= /* n%VComment%n*/ ;fClip(CommentStruct) ;mf_PasteVar(CommentStruct) fClip(CommentStruct) return

Gewerd-Strauss commented 3 years ago

I have found a way to circumvent this issue, which at least works for what I've been using this for. I do not know if it will negatively impact other functionality of the function, but here goes. In lines 29 and 31, before returning each time, I have deactivated the %A_ThisFunc%-timer again.