Detect text colour/format in clipboard Topic is solved

Get help with using AutoHotkey (v2 or newer) and its commands and hotkeys
Draken
Posts: 96
Joined: 08 Dec 2022, 01:19

Detect text colour/format in clipboard

22 May 2024, 02:55

Hello, is there any way to find out the color/formatting text in the clipboard? If I copy text and paste it into MS Word the text color is transferred, so its format must be saved in clipboard. Specifically, I would like to find out what line the red text is on. Ideally not looking for a specific text color, but text that is the only one that is a different color than the other lines. Thank you.

150 g Liver sausage with vinegar and onion, bread
100 g Beer cheese, butter, onion, toasts
100 g Pork crackling spread, bread

1 pcs Pickled Hermelín (cheese with white mould), bread
100 g Prague ham with butter and pickled cucumber, bread
100 g Smoked pork neck with horseradish and pickled cucumber, bread
Draken
Posts: 96
Joined: 08 Dec 2022, 01:19

Re: Detect text colour/format in clipboard

25 May 2024, 03:29

Is there really no way to find out the colour of the text?
teadrinker
Posts: 4412
Joined: 29 Mar 2015, 09:41
Contact:

Re: Detect text colour/format in clipboard

25 May 2024, 03:46

Where are you copying the text from?
User avatar
Noitalommi_2
Posts: 332
Joined: 16 Aug 2023, 10:58

Re: Detect text colour/format in clipboard  Topic is solved

25 May 2024, 07:57

Hi.

I played around with ClipboardAll() and this is the result. It goes through the binary code in the clipboard once and returns the character codes
and copies it all back into the clipboard, which you can then paste into an editor. It seems to have formatted code where the color can be found.
You could use InStr or RegEx to work further with.

Code: Select all

#Requires AutoHotkey 2.0
#SingleInstance

F1:: {

    ClipSaved := ClipboardAll()
    Loop ClipSaved.Size {

        if Num := NumGet(ClipSaved.Ptr, A_Index-1, "UChar")
            ClipBoard .= Chr(Num)
    }
    A_Clipboard := ClipBoard ?? "empty"
    SoundBeep
}
The Twitch link in the email looks something like this:
style='color:#9147FF;text-decoration:none;text-underline:none'>Someone is live!</span></a></span></b><!--EndFragment-->

Here I tested with OpenOffice and a red text:
<TD WIDTH=152 HEIGHT=19 ALIGN=LEFT VALIGN=BOTTOM><FONT FACE="Calibri" COLOR="#FF3333">MyTExt</FONT></TD>

It's something to work with.
Edit: After some testing, putting everthing in a var to search for keywords works. But the search pattern depends on where you copied from.

Return to “Ask for Help (v2)”

Who is online

Users browsing this forum: No registered users and 10 guests