OnClipboardChange

OnClipboardChange() [v1.1.20+]

클립보드의 내용이 변경될 때마다 실행될 함수 또는 함수 객체를 등록합니다.

OnClipboardChange(Func , AddRemove)

매개변수

Func

호출할 함수 이름 또는 함수 객체. 함수의 매개변수와 반환 값은 아래에 기술합니다.

AddRemove

If blank or omitted, it defaults to 1 (call the function after any previously registered functions). Otherwise, specify one of the following numbers:

OnClipboardChange 라벨이 존재하면, 언제나 먼저 호출됩니다.

Func

FunctionName(Type)
Type

Contains one of the following numbers:

반환 값

이것이 마지막 함수 또는 유일한 OnClipboardChange 함수라면 반환값은 무시됩니다. 그렇지 않으면, 함수는 0 아닌 값을 돌려주어 연이어서 다른 함수가 호출되지 못하도록 막습니다.

OnClipboardChange 라벨

비추천: 이 접근법는 새 스크립트에 사용을 추천하지 않습니다. 대신 OnClipboardChange 기능을 사용하십시오.

어플리케이션이 (스크립트도 마찬가지로) 클립보드의 내용을 변경할 때마다 (존재한다면) 이름이 OnClipboardChange인 라벨이 자동으로 기동됩니다. 이 라벨은 또 스크립트가 처음 시작할 때 한 번 실행됩니다.

The built-in variable A_EventInfo contains one of the following numbers:

논평

If the clipboard changes while an OnClipboardChange function or label is already running, that notification event is lost. 이것이 바람직하지 않다면, Critical을 라벨의 첫 줄에 지정하십시오. 그렇지만, 이것은 또 OnClipboardChange 쓰레드가 실행 중인 동안에 일어나는 다른 쓰레드를 (예를 들어 핫키 누름을) 버퍼처리/연기합니다.

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

Clipboard, OnExit(), OnExit, OnMessage(), RegisterCallback()

예제

Function vs. Label.

Despite the different approach, both examples have the same effect; that is, they briefly display a tooltip for each clipboard change. Note that the function is not called when the script first starts; only when the contents of the clipboard changes.

#Persistent
OnClipboardChange("ClipChanged")
return

ClipChanged(Type) {
    ToolTip Clipboard data type: %Type%
    Sleep 1000
    ToolTip  ; 팁을 끕니다.
}
#Persistent
return

OnClipboardChange:
ToolTip Clipboard data type: %A_EventInfo%
Sleep 1000
ToolTip  ; 팁을 끕니다.
return