Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate

Check if the clipboard contains a picture


  • Please log in to reply
6 replies to this topic
  • Guests
  • Last active:
  • Joined: --
The OnClipBoardChange label seems to be able to distinguish only text and binary data. So how do I know if an image is copied in the clipboard or not?

Odlanir
  • Members
  • 775 posts
  • Last active: Mar 06 2014 11:02 AM
  • Joined: 07 Aug 2011
The AutoHotkey Help installed with Autohotkey should be the first place to look in when we need help.

If you don't know how to get help you can use this.
run % RegExReplace(A_AhkPath, ".exe", ".chm")

A label named OnClipboardChange (if it exists) is launched automatically whenever any application (even the script itself) has changed the contents of the clipboard. The label also runs once when the script first starts.

The built-in variable A_EventInfo contains:
0 if the clipboard is now empty;
1 if it contains something that can be expressed as text (this includes files copied from an Explorer window);
2 if it contains something entirely non-text such as a picture.

The following example is a working script. Whenever it is running, it will briefly display a ToolTip for each clipboard change.


#Persistent
return

OnClipboardChange:
	ToolTip Clipboard data type: %A_EventInfo%
	Sleep 1000
	ToolTip  ; Turn off the tip.
return


  • Guests
  • Last active:
  • Joined: --
Can you tell if it is exactly a picture and not other types of binary data?

fragman
  • Members
  • 1591 posts
  • Last active: Nov 12 2012 08:51 PM
  • Joined: 13 Oct 2009
You can, check up on IsClipboardFormatAvailable on MSDN.

  • Guests
  • Last active:
  • Joined: --
Thanks fragman. You are a sort of lifesaver. It was really an annoying moment that a RTFM guy appeared without reading the question.
if DllCall("IsClipboardFormatAvailable", "Uint", 2)	;2:CF_BITMAP
	msgbox it's bitmap
else
	msgbox something else


Odlanir
  • Members
  • 775 posts
  • Last active: Mar 06 2014 11:02 AM
  • Joined: 07 Aug 2011

It was really an annoying moment that a RTFM guy appeared without reading the question.

Guest Sorry 'bout that. I misunderstood your question. But, anyway, I was only trying to helps you, not to offend you. I've learn a good lesson.
Thank you.

Regards.

tomoe_uehara
  • Members
  • 2166 posts
  • Last active: Jun 11 2015 05:33 PM
  • Joined: 05 Sep 2009
+1
Afterall we're not paid to help anyone here, aren't we?