Jump to content


Check if the clipboard contains a picture


  • Please log in to reply
6 replies to this topic

#1 Guests

  • Guests

Posted 05 October 2011 - 10:19 AM

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?

#2 Odlanir

Odlanir
  • Members
  • 754 posts

Posted 05 October 2011 - 11:01 AM

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


#3 Guests

  • Guests

Posted 05 October 2011 - 11:24 AM

Can you tell if it is exactly a picture and not other types of binary data?

#4 fragman

fragman
  • Members
  • 1591 posts

Posted 05 October 2011 - 11:41 AM

You can, check up on IsClipboardFormatAvailable on MSDN.

#5 Guests

  • Guests

Posted 05 October 2011 - 11:49 AM

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


#6 Odlanir

Odlanir
  • Members
  • 754 posts

Posted 05 October 2011 - 12:59 PM

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.

#7 tomoe_uehara

tomoe_uehara
  • Members
  • 2073 posts

Posted 05 October 2011 - 01:01 PM

+1
Afterall we're not paid to help anyone here, aren't we?