Hi,
I want to trim Clipboard after pressing Control+C. It's quiteannoying as when I double click in a word, selection usually includes a space at the rightmost position. I want to trim the clipboard when pressing Control C.
Well, I am trying this (variations are welcome)
$^c:: ; I UNDERSTAND THIS $ SIGN IS NECESSARY TO USE THE SYSTEM CONTROL-C WITHIN THE HOTKEY. IT DOES NOT WORK WITHOUT IT.
SendInput ^c ; A SIMPLE COPY COMMAND (IT'S NOT COMPLETELY RELIABLE, I DON'T KNOW WHY, I USE VARIATIONS AS WELL)
Clipboard := Rtrim(clipboard, OmitChars := " ") ; TRIMS WHEN IT WANTS, DOESN'T TRIM A DAMN REST OF THE TIME
Return
and it works RANDOMLY. Sometimes it trims, sometimes it doesn't. Of course, I have previously tried all possible variations I can think of, both for SendInput ^c or SendInput {Control Down}c{Control Up} as for Clipboard=%Clipboard%, ClipBoard=Trim (clipboard), etc.
Of course, either it works RANDOMLY or it doesn't work at all (I suppose that happens when I use a wrong or incorrect syntax) but I have never got this to work 100% of the time!!
WHY???
Trim working randomly!
Re: Trim working randomly!
You can avoid this easily without the need of a script. Double click on a word but do not release the left mouse button. Now move the mouse over the word in any direction once, as little as possible (to avoid selecting other words too).I want to trim Clipboard after pressing Control+C. It's quiteannoying as when I double click in a word, selection usually includes a space at the rightmost position. I want to trim the clipboard when pressing Control C.
-
- Posts: 1472
- Joined: 05 May 2018, 12:23
Re: Trim working randomly!
That is a real good tip, been using computers for a long time never knew thatFlipeador wrote:You can avoid this easily without the need of a script. Double click on a word but do not release the left mouse button. Now move the mouse over the word in any direction once, as little as possible (to avoid selecting other words too).I want to trim Clipboard after pressing Control+C. It's quiteannoying as when I double click in a word, selection usually includes a space at the rightmost position. I want to trim the clipboard when pressing Control C.
Re: Trim working randomly!
I absolutely don't know what you are talking aboutYou can avoid this easily without the need of a script. Double click on a word but do not release the left mouse button. Now move the mouse over the word in any direction once, as little as possible (to avoid selecting other words too).
I have tried double clicking without releasing the left mouse button in the second click, moving a bit, and the selection does not change (nor is the space at the right removed) unless I move the pointer out of the word. And, in that case, there is no advantage at all, it's even slower than copypasting with a space ant then deleting it.
I want to trim the ClipBoard.. and my script above does not help. Any ideas?
Re: Trim working randomly!
I don't think so. I think if you have a decent mouse, and a minimum of skill to use it, it's just as fast. Therefore, you have an advantage.there is no advantage at all, it's even slower than copypasting with a space ant then deleting it
-
- Posts: 1472
- Joined: 05 May 2018, 12:23
Re: Trim working randomly!
can you please share what program did you use to make that animation?Flipeador wrote:I don't think so. I think if you have a decent mouse, and a minimum of skill to use it, it's just as fast. Therefore, you have an advantage.there is no advantage at all, it's even slower than copypasting with a space ant then deleting it
let me know if the image is not visible
Re: Trim working randomly!
I want to trim the ClipBoard.. and my script above does not help. Any ideas?
Code: Select all
#Persistent
OnClipboardChange("OCC")
Return
OCC(Type)
{
If (Type == 1)
Clipboard := RTrim(Clipboard)
}
Re: Trim working randomly!
Err.. sorry Flipeador, but since I don't understand anything of what you just did with the OnclipboardChange and all that (that's definitely about my script level, wow!), could you please tell me how to integrate that in my
script.. Should this go in any place of my script? Substitute what? Change what for what?
By the way, your animation was amazing but I can tell you that does not work in my system. I keep trying it and no space is trimmed, perhaps my mouse sucks or something, but it's not working so I need the script...
Amazing how some of you guys know so much!
Code: Select all
$^c::
SendInput ^c ;
Clipboard := Rtrim(clipboard, OmitChars := " ")
Return
By the way, your animation was amazing but I can tell you that does not work in my system. I keep trying it and no space is trimmed, perhaps my mouse sucks or something, but it's not working so I need the script...
Amazing how some of you guys know so much!
Re: Trim working randomly!
Hey Flipeador!
I just put your code in the script, no hotkey, no nothing, and it works! It itches me a bit to find out I have absolutely no idea why or what the heck this is doing, but it is friggin' amazing. Dude, thank you!!! I would LOVE to know why my approach worked randomly though... I sincerely don't understand AutoHotkey sometimes
I just put your code in the script, no hotkey, no nothing, and it works! It itches me a bit to find out I have absolutely no idea why or what the heck this is doing, but it is friggin' amazing. Dude, thank you!!! I would LOVE to know why my approach worked randomly though... I sincerely don't understand AutoHotkey sometimes
Re: Trim working randomly!
With OnclipboardChange is the best way to do it, since you do not have to use SendInput and declare a hotkey. Although... if text is established in another way, it also takes away the space...Nixcalo wrote:Err.. sorry Flipeador, but since I don't understand anything of what you just did with the OnclipboardChange and all that (that's definitely about my script level, wow!), could you please tell me how to integrate that in my
Code: Select all
~^c::
SetTimer Label, -250
Return
Label:
Clipboard := RTrim(Clipboard)
Return
Code: Select all
$^c::
SendInput {lctrl down}c{lctrl up}
Sleep 250
Clipboard := Rtrim(Clipboard, A_Space)
Return
Edit*
The problem in your script is that when you do SendInput ^c you have to wait until the text is copied to the clipboard (it is not instant), SendInput returns but the text has not yet been copied. And... you do not need OmitChars in the second parameter of RTrim function. As for the rest, just read the documentation, it's very complete and clear.Nixcalo wrote:I sincerely don't understand AutoHotkey sometimes
Re: Trim working randomly!
One tiny observation, Flipeador. While I see that your script seems to work great while in text environments, your script messes up Copy /Ppaste of files in Windows... or at least I am no longer able to copy and paste a file from the Windows Explorer...
Just so you know! I guess it would be a good idea then to limit your part of the script only when a certain Window (or program) is active. I will check that out!
Just so you know! I guess it would be a good idea then to limit your part of the script only when a certain Window (or program) is active. I will check that out!
Re: Trim working randomly! || SetClipboardText
Code: Select all
~^c:: SetTimer Label, -250
Label:
SetClipboardText( RTrim(Clipboard) )
Return
SetClipboardText(Text)
{
DllCall("User32.dll\OpenClipboard", "Ptr", A_ScriptHwnd)
pMem := DllCall("Kernel32.dll\GlobalAlloc", "UInt", 0x42, "UPtr", StrPut(Text, "UTF-16") * 2, "UPtr")
pLock := DllCall("Kernel32.dll\GlobalLock", "UPtr", pMem, "UPtr")
StrPut(Text, pLock, "UTF-16")
DllCall("Kernel32.dll\GlobalUnlock", "UPtr", pMem, "UPtr")
Ret := DllCall("User32.dll\SetClipboardData", "UInt", 13, "UPtr", pMem, "UPtr") ; CF_UNICODETEXT = 13
DllCall("User32.dll\CloseClipboard")
If (!Ret)
DllCall("Kernel32.dll\GlobalFree", "UPtr", pMem, "UPtr")
Return Ret
}
-
- Posts: 1472
- Joined: 05 May 2018, 12:23
Who is online
Users browsing this forum: balawi28, Bing [Bot], Google [Bot] and 228 guests