Registers a function or function object to run whenever the clipboard's content changes.

OnClipboardChange Func , AddRemove



Type: String or Object

A function name or function object to call. The function's parameter and return value are described below.


Type: Integer

One of the following values:
1 (the default): Call the function after any previously registered functions.
-1: Call the function before any previously registered functions.
0: Do not call the function.



Type: Integer

Contains one of the following values:
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.

Return Value

Type: Integer

If this is the last or only OnClipboardChange function, the return value is ignored. Otherwise, the function can return a non-zero integer to prevent subsequent functions from being called.


If the clipboard changes while an OnClipboardChange function is already running, that notification event is lost. If this is undesirable, use Critical. However, this will also buffer/defer other threads (such as the press of a hotkey) that occur while the OnClipboardChange thread is running.

If the script itself changes the clipboard, its OnClipboardChange functions are typically not executed immediately; that is, functions immediately below the function that changed the clipboard are likely to execute beforehand. To force the functions to execute immediately, use a short delay such as Sleep 20 after changing the clipboard.


A_Clipboard, OnExit, OnMessage, CallbackCreate


#1: The following script will briefly display a ToolTip for each clipboard change:


ClipChanged(clip_type) {
    ToolTip "Clipboard data type: " clip_type
    Sleep 1000
    ToolTip  ; Turn off the tip.