Jump to content

How do one recognises SELF while processing a WM_DRAWCLIPBOARD ?!


Armand
 Share

Recommended Posts

well, i know i can use:

$GUIm = guicreate(...)
...
Func  WM_DRAWCLIPBOARDtrack()
if WinActive ($GUIm) then return
;process anything not from my gui here...
Endfunc

but i was wandering if there is any way to get my OWN location in the clipboard chain and thus intercepting it while processing ?!

since i would like to disable clipboard operation of specific GUIs while they are also in an inactive mode...

thanks in advance!

[u]My Au3 Scripts:[/u]____________(E)Lephant, A Share download manager (RS/MU etc)Http1.1 Console, The Ez Way!Internet Reconnection Automation Suite & A Macro Recording Tool.SK's Alarm Clock, Playing '.MP3 & .Wav' Files._________________Is GOD a mistake of the Humanity Or the Humanity is a mistake of GOD ?!

Link to comment
Share on other sites

Here is something what can help you:

#include <GUIConstants.au3>

;~ Global Const $WM_DRAWCLIPBOARD = 0x0308
;~ Global Const $WM_CHANGECBCHAIN = 0x030D

Global $origHWND

$gui = GUICreate("Clip Hook",400,400,-1,-1,BitOR($WS_CAPTION,$WS_SYSMENU))

; remember last clip viewer in queue and set our GUI as first in queue
$origHWND = DLLCall("user32.dll","hwnd","SetClipboardViewer","hwnd",$gui)
$origHWND = $origHWND[0]

GUIRegisterMsg($WM_DRAWCLIPBOARD,"OnClipBoardChange")
GUIRegisterMsg($WM_CHANGECBCHAIN,"OnClipBoardViewerChange")

GUISetState()

While 1
    $msg = GUIGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
WEnd

; send notification that we no longer will be in clipboard hook queue
DLLCall("user32.dll","int","ChangeClipboardChain","hwnd",$gui,"hwnd",$origHWND)
Exit

Func OnClipBoardChange($hWnd, $Msg, $wParam, $lParam)
    ; do what you need when clipboard changes
    ToolTip(ClipGet())
    Sleep(3000)
    ToolTip("")
        ; send notification about clipboard change to next clipviewer
    dllcall("user32.dll","int","SendMessage","hWnd",$origHWND,"int",$WM_DRAWCLIPBOARD,"int",$wParam,"int",$lParam)
EndFunc

Func OnClipBoardViewerChange($hWnd, $Msg, $wParam, $lParam)
    ; if our remembered previous clipviewer is removed then we must remember new next clipviewer
    ; else send notification about clipviewer change to next clipviewer
    If $wParam = $origHWND Then
        $origHWND = $lParam
    Else
        dllcall("user32.dll","int","SendMessage","hWnd",$origHWND,"int",$WM_CHANGECBCHAIN,"hwnd",$wParam,"hwnd",$lParam)
    EndIf
EndFunc
Link to comment
Share on other sites

Thanks alot mate, but u can already use the built it UDFs from the latest beta to have it working just the same...

-> but i've searched all over and i can't seem to be able to find out:

->>> How do i know what window has Launched the "WM_DRAWCLIPBOARD" msg ?! where has we clicked [copy] ?!

-> i'f i'll be able to find that out it'll solve my issue.

P.S - @Zedna Thanks a lot for minding my question and replying to it!

___________________ EDIT:

can one register "WM_COPY" & "WM_CUT" events ?! How ?! [i'll be trying...]

___________________ EDIT:

Well... since that msg is sent directly to the control i guess u can't [tried]

by micro:

"WM_COPY Message

An application sends the WM_COPY message to an edit control or combo box to copy the current selection to the clipboard in CF_TEXT format. "

Edited by Armand

[u]My Au3 Scripts:[/u]____________(E)Lephant, A Share download manager (RS/MU etc)Http1.1 Console, The Ez Way!Internet Reconnection Automation Suite & A Macro Recording Tool.SK's Alarm Clock, Playing '.MP3 & .Wav' Files._________________Is GOD a mistake of the Humanity Or the Humanity is a mistake of GOD ?!

Link to comment
Share on other sites

here is a complete ""REMAKE"" of my issue...

#include <ClipBoard.au3>
#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include <SendMessage.au3>

Opt('MustDeclareVars', 1)

Global $iMemo, $hGUI, $BUTT, $BUTT2, $hNext = 0

_Main()

Func _Main()
    ; Create GUI
    $hGUI = GUICreate("Clipboard", 600, 450)
    $iMemo = GUICtrlCreateEdit("", 2, 2, 596, 396, $WS_VSCROLL)
    GUICtrlSetFont($iMemo, 9, 400, 0, "Courier New")
    $BUTT = GUICtrlCreateButton("_ClipBoard_SetData",15,400, 50,20)
    $BUTT2 = GUICtrlCreateButton("ClipPut",75,400, 50,20)
    GUISetState()

    ; Initialize clipboard viewer
    $hNext = _ClipBoard_SetViewer ($hGUI)

    GUIRegisterMsg($WM_CHANGECBCHAIN, "WM_CHANGECBCHAIN")
    GUIRegisterMsg($WM_DRAWCLIPBOARD, "WM_DRAWCLIPBOARD")

    ; Loop until user exits
    Do
        Switch GUIGetMsg()
            Case $BUTT
                _ClipBoard_SetData ("************_ClipBoard_SetData************")
            Case $BUTT2
                ClipPut("(************ClipPut************")
        EndSwitch
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Shut down clipboard viewer
    _ClipBoard_ChangeChain ($hGUI, $hNext)
EndFunc   ;==>_Main

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($iMemo, GUICtrlRead($iMemo)& @CRLF&"_________________________________________" & @CRLF&$sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite

; Handle $WM_CHANGECBCHAIN messages
Func WM_CHANGECBCHAIN($hWnd, $iMsg, $iwParam, $ilParam)
    ; Show that message was received
    MemoWrite("***** $WM_CHANGECBCHAIN *****")

    ; If the next window is closing, repair the chain
    If $iwParam = $hNext Then
        $hNext = $ilParam
        ; Otherwise pass the message to the next viewer
    ElseIf $hNext <> 0 Then
        _SendMessage ($hNext, $WM_CHANGECBCHAIN, $iwParam, $ilParam, 0, "hwnd", "hwnd")
    EndIf
EndFunc   ;==>WM_CHANGECBCHAIN

; Handle $WM_DRAWCLIPBOARD messages
Func WM_DRAWCLIPBOARD($hWnd, $iMsg, $iwParam, $ilParam)
    MemoWrite(@TAB&"$hWnd="&$hWnd&" $iMsg="&$iMsg&" $iwParam: "&$iwParam&" $ilParam:"&$ilParam&@CRLF & _
    "$hGUI="&$hGUI&" $hNext="&$hNext&" GetOwner()="&_ClipBoard_GetOwner()&" GetViewer()="&_ClipBoard_GetViewer()&@CRLF)
    ; Display any text on clipboard
    MemoWrite(_ClipBoard_GetData ())

    ; Pass the message to the next viewer
    If $hNext <> 0 Then _SendMessage ($hNext, $WM_DRAWCLIPBOARD, $iwParam, $ilParam)
EndFunc   ;==>WM_DRAWCLIPBOARD

as simple as it can be... just need to know how to disable specific clipboard copies by parsing the clipboard effecting window.

[u]My Au3 Scripts:[/u]____________(E)Lephant, A Share download manager (RS/MU etc)Http1.1 Console, The Ez Way!Internet Reconnection Automation Suite & A Macro Recording Tool.SK's Alarm Clock, Playing '.MP3 & .Wav' Files._________________Is GOD a mistake of the Humanity Or the Humanity is a mistake of GOD ?!

Link to comment
Share on other sites

well.. was trying to register : WM_CLIPBOARDUPDATE, seems like it isn't thrown at me, like never...

MICRO:

"WM_CLIPBOARDUPDATE Notification

Sent when the contents of the clipboard have changed."

so... ?!

PS. maybe i got the const wrong ?!

#include <ClipBoard.au3>
#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include <SendMessage.au3>

Opt('MustDeclareVars', 1)

Global $iMemo, $hGUI, $BUTT, $BUTT2, $hNext = 0
Const $WM_CLIPBOARDUPDATE = 0x031D

_Main()

Func _Main()
    Local $Ret
    
    ; Create GUI
    $hGUI = GUICreate("Clipboard", 600, 450)
    $iMemo = GUICtrlCreateEdit("", 2, 2, 596, 396, $WS_VSCROLL)
    GUICtrlSetFont($iMemo, 9, 400, 0, "Courier New")
    $BUTT = GUICtrlCreateButton("_ClipBoard_SetData",15,400, 50,20)
    $BUTT2 = GUICtrlCreateButton("ClipPut",75,400, 50,20)
    GUISetState()

    ; Initialize clipboard viewer
    $hNext = _ClipBoard_SetViewer ($hGUI)

    GUIRegisterMsg($WM_CHANGECBCHAIN, "WM_CHANGECBCHAIN")
    GUIRegisterMsg($WM_DRAWCLIPBOARD, "WM_DRAWCLIPBOARD")
    $Ret = GUIRegisterMsg($WM_CLIPBOARDUPDATE, "WM_CLIPBOARDUPDATE")
    If $Ret = 0 Then MsgBox(0,"","SHIT")

    ; Loop until user exits
    Do
        Switch GUIGetMsg()
            Case $BUTT
                _ClipBoard_SetData ("************_ClipBoard_SetData************")
            Case $BUTT2
                ClipPut("(************ClipPut************")
        EndSwitch
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Shut down clipboard viewer
    _ClipBoard_ChangeChain ($hGUI, $hNext)
EndFunc   ;==>_Main

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($iMemo, GUICtrlRead($iMemo)& @CRLF&"_________________________________________" & @CRLF&$sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite

; Handle $WM_CHANGECBCHAIN messages
Func WM_CHANGECBCHAIN($hWnd, $iMsg, $iwParam, $ilParam)
    ; Show that message was received
    MemoWrite("***** $WM_CHANGECBCHAIN *****")

    ; If the next window is closing, repair the chain
    If $iwParam = $hNext Then
        $hNext = $ilParam
        ; Otherwise pass the message to the next viewer
    ElseIf $hNext <> 0 Then
        _SendMessage ($hNext, $WM_CHANGECBCHAIN, $iwParam, $ilParam, 0, "hwnd", "hwnd")
    EndIf
EndFunc   ;==>WM_CHANGECBCHAIN

; Handle $WM_DRAWCLIPBOARD messages
Func WM_DRAWCLIPBOARD($hWnd, $iMsg, $iwParam, $ilParam)
    MemoWrite(@TAB&"$hWnd="&$hWnd&" $iMsg="&$iMsg&" $iwParam: "&$iwParam&" $ilParam:"&$ilParam&@CRLF & _
    "$hGUI="&$hGUI&" $hNext="&$hNext&" GetOwner()="&_ClipBoard_GetOwner()&" GetViewer()="&_ClipBoard_GetViewer()&@CRLF)
    ; Display any text on clipboard
    MemoWrite(_ClipBoard_GetData ())

    ; Pass the message to the next viewer
    If $hNext <> 0 Then _SendMessage ($hNext, $WM_DRAWCLIPBOARD, $iwParam, $ilParam)
EndFunc   ;==>WM_DRAWCLIPBOARD
    
Func WM_CLIPBOARDUPDATE($hWnd, $iMsg, $iwParam, $ilParam)
    MsgBox(0,"",@TAB&"$hWnd="&$hWnd&" $iMsg="&$iMsg&" $iwParam: "&$iwParam&" $ilParam:"&$ilParam&@CRLF & _
    "$hGUI="&$hGUI&" $hNext="&$hNext&" GetOwner()="&_ClipBoard_GetOwner()&" GetViewer()="&_ClipBoard_GetViewer()&@CRLF)
EndFunc

Is it oky that i'm writing soo much without being answered?!

EDIT:

seems like when i'm using the above script, and i'm 'CTRL+C'[copying] stuff from different windows it throws a fatal error.

Edited by Armand

[u]My Au3 Scripts:[/u]____________(E)Lephant, A Share download manager (RS/MU etc)Http1.1 Console, The Ez Way!Internet Reconnection Automation Suite & A Macro Recording Tool.SK's Alarm Clock, Playing '.MP3 & .Wav' Files._________________Is GOD a mistake of the Humanity Or the Humanity is a mistake of GOD ?!

Link to comment
Share on other sites

here is a complete ""REMAKE"" of my issue...

#include <ClipBoard.au3>
#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include <SendMessage.au3>

Opt('MustDeclareVars', 1)

Global $iMemo, $hGUI, $BUTT, $BUTT2, $hNext = 0

_Main()

Func _Main()
    ; Create GUI
    $hGUI = GUICreate("Clipboard", 600, 450)
    $iMemo = GUICtrlCreateEdit("", 2, 2, 596, 396, $WS_VSCROLL)
    GUICtrlSetFont($iMemo, 9, 400, 0, "Courier New")
    $BUTT = GUICtrlCreateButton("_ClipBoard_SetData",15,400, 50,20)
    $BUTT2 = GUICtrlCreateButton("ClipPut",75,400, 50,20)
    GUISetState()

    ; Initialize clipboard viewer
    $hNext = _ClipBoard_SetViewer ($hGUI)

    GUIRegisterMsg($WM_CHANGECBCHAIN, "WM_CHANGECBCHAIN")
    GUIRegisterMsg($WM_DRAWCLIPBOARD, "WM_DRAWCLIPBOARD")

    ; Loop until user exits
    Do
        Switch GUIGetMsg()
            Case $BUTT
                _ClipBoard_SetData ("************_ClipBoard_SetData************")
            Case $BUTT2
                ClipPut("(************ClipPut************")
        EndSwitch
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Shut down clipboard viewer
    _ClipBoard_ChangeChain ($hGUI, $hNext)
EndFunc   ;==>_Main

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($iMemo, GUICtrlRead($iMemo)& @CRLF&"_________________________________________" & @CRLF&$sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite

; Handle $WM_CHANGECBCHAIN messages
Func WM_CHANGECBCHAIN($hWnd, $iMsg, $iwParam, $ilParam)
    ; Show that message was received
    MemoWrite("***** $WM_CHANGECBCHAIN *****")

    ; If the next window is closing, repair the chain
    If $iwParam = $hNext Then
        $hNext = $ilParam
        ; Otherwise pass the message to the next viewer
    ElseIf $hNext <> 0 Then
        _SendMessage ($hNext, $WM_CHANGECBCHAIN, $iwParam, $ilParam, 0, "hwnd", "hwnd")
    EndIf
EndFunc   ;==>WM_CHANGECBCHAIN

; Handle $WM_DRAWCLIPBOARD messages
Func WM_DRAWCLIPBOARD($hWnd, $iMsg, $iwParam, $ilParam)
    MemoWrite(@TAB&"$hWnd="&$hWnd&" $iMsg="&$iMsg&" $iwParam: "&$iwParam&" $ilParam:"&$ilParam&@CRLF & _
    "$hGUI="&$hGUI&" $hNext="&$hNext&" GetOwner()="&_ClipBoard_GetOwner()&" GetViewer()="&_ClipBoard_GetViewer()&@CRLF)
    ; Display any text on clipboard
    MemoWrite(_ClipBoard_GetData ())

    ; Pass the message to the next viewer
    If $hNext <> 0 Then _SendMessage ($hNext, $WM_DRAWCLIPBOARD, $iwParam, $ilParam)
EndFunc   ;==>WM_DRAWCLIPBOARD

as simple as it can be... just need to know how to disable specific clipboard copies by parsing the clipboard effecting window.

I am using AutoIt 3.2.11.0

I cannot run your example without AutoIt3 crashing if I copy text to the clipboard. Sometimes it crashes immediately the first time I copy, sometimes it might be the fifth time I copy.

I have exactly the same problem with the example from the helpfile for _ClipBoard_GetViewer .

I have tried many things but the only conclusion I have reached is that the problem is to do with _ClipBoard_GetData ().

Anyone else have this problem?

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

@martin

It crashes to me only when i register "Global Const $WM_CLIPBOARDUPDATE = 0x031D"

without it everything works fine... except it's always processing self msgs also!!

[u]My Au3 Scripts:[/u]____________(E)Lephant, A Share download manager (RS/MU etc)Http1.1 Console, The Ez Way!Internet Reconnection Automation Suite & A Macro Recording Tool.SK's Alarm Clock, Playing '.MP3 & .Wav' Files._________________Is GOD a mistake of the Humanity Or the Humanity is a mistake of GOD ?!

Link to comment
Share on other sites

@martin

It crashes to me only when i register "Global Const $WM_CLIPBOARDUPDATE = 0x031D"

without it everything works fine... except it's always processing self msgs also!!

The code below works without the AutoIt crashes.

#include <ClipBoard.au3>
#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include <SendMessage.au3>
#include <misc.au3>

Opt('MustDeclareVars', 1)

Global $iMemo, $hGUI, $BUTT, $BUTT2, $hNext = 0, $la

_Main()

Func _Main()
; Create GUI
    $hGUI = GUICreate("Clipboard - unique", 600, 450)
    $iMemo = GUICtrlCreateEdit("", 2, 2, 596, 396, $WS_VSCROLL)
    GUICtrlSetFont($iMemo, 9, 400, 0, "Courier New")
    $BUTT = GUICtrlCreateButton("_ClipBoard_SetData", 15, 400, 50, 20)
    $BUTT2 = GUICtrlCreateButton("ClipPut", 75, 400, 50, 20)
    GUISetState()

; Initialize clipboard viewer
    $hNext = _ClipBoard_SetViewer($hGUI)

    GUIRegisterMsg($WM_CHANGECBCHAIN, "WM_CHANGECBCHAIN")
    GUIRegisterMsg($WM_DRAWCLIPBOARD, "WM_DRAWCLIPBOARD")
    $la = $hGUI
; Loop until user exits
    Do
        GetLastActive($la, "Clipboard - unique")
        Switch GUIGetMsg()
            Case $BUTT
                _ClipBoard_SetData("************_ClipBoard_SetData************")
            Case $BUTT2
                ClipPut("(************ClipPut************")
        EndSwitch
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

; Shut down clipboard viewer
    _ClipBoard_ChangeChain($hGUI, $hNext)
EndFunc  ;==>_Main

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($iMemo, GUICtrlRead($iMemo) & @CRLF & "_________________________________________" & @CRLF & $sMessage & @CRLF, 1)
EndFunc  ;==>MemoWrite

; Handle $WM_CHANGECBCHAIN messages
Func WM_CHANGECBCHAIN($hWnd, $iMsg, $iwParam, $ilParam)
; Show that message was received
    MemoWrite("***** $WM_CHANGECBCHAIN *****")

; If the next window is closing, repair the chain
    If $iwParam = $hNext Then
        $hNext = $ilParam
    ; Otherwise pass the message to the next viewer
    ElseIf $hNext <> 0 Then
        _SendMessage($hNext, $WM_CHANGECBCHAIN, $iwParam, $ilParam, 0, "hwnd", "hwnd")
    EndIf
EndFunc  ;==>WM_CHANGECBCHAIN




; Handle $WM_DRAWCLIPBOARD messages
Func WM_DRAWCLIPBOARD($hWnd, $iMsg, $iwParam, $ilParam)

    WinActivate($hGUI)
    GUICtrlSetState($iMemo, $GUI_FOCUS)

    Send("^{END}")
    Send("{ENTER}")
    Send("^v")
    
    
    If $la <> "Clipboard - unique" Then WinActivate($la)

; Pass the message to the next viewer
    If $hNext <> 0 Then _SendMessage($hNext, $WM_DRAWCLIPBOARD, $iwParam, $ilParam)
EndFunc  ;==>WM_DRAWCLIPBOARD

;Find the active window butignore windows with $sExclude in the title
Func GetLastActive(ByRef $lla, $sExclude)
    Local $wa = WinGetTitle('');gets the title of the currently active window
    If Not StringInStr($wa, $sExclude) And $wa <> '' Then $lla = $wa
EndFunc  ;==>GetLastActive

I have had problems with using Send when there is a Control key sequence. Sometimes the Ctrl key gets 'latched' and after the script is stopped I have to press the Ctrl to release it. If I run the script above sometimes I get the problem sometimes I don't. I think there is something wrong with Send but I can't pin it down.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

sorry mate but i've tried what u've made... i don't quite get the point of it...

#include <ClipBoard.au3>
#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include <SendMessage.au3>

Opt('MustDeclareVars', 1)

Global $iMemo, $hGUI, $BUTT, $BUTT2, $hNext = 0

_Main()

Func _Main()
    ; Create GUI
    $hGUI = GUICreate("Clipboard", 600, 450)
    $iMemo = GUICtrlCreateEdit("", 2, 2, 596, 396, $WS_VSCROLL)
    GUICtrlSetFont($iMemo, 9, 400, 0, "Courier New")
    $BUTT = GUICtrlCreateButton("_ClipBoard_SetData",15,400, 50,20)
    $BUTT2 = GUICtrlCreateButton("ClipPut",75,400, 50,20)
    GUISetState()

    ; Initialize clipboard viewer
    $hNext = _ClipBoard_SetViewer ($hGUI)

    GUIRegisterMsg($WM_CHANGECBCHAIN, "WM_CHANGECBCHAIN")
    GUIRegisterMsg($WM_DRAWCLIPBOARD, "WM_DRAWCLIPBOARD")

    ; Loop until user exits
    Do
        Switch GUIGetMsg()
            Case $BUTT
                _ClipBoard_SetData ("************_ClipBoard_SetData************")
            Case $BUTT2
                ClipPut("(************ClipPut************")
        EndSwitch
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Shut down clipboard viewer
    _ClipBoard_ChangeChain ($hGUI, $hNext)
EndFunc   ;==>_Main

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($iMemo, GUICtrlRead($iMemo)& @CRLF&"_________________________________________" & @CRLF&$sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite

; Handle $WM_CHANGECBCHAIN messages
Func WM_CHANGECBCHAIN($hWnd, $iMsg, $iwParam, $ilParam)
    ; Show that message was received
    MemoWrite("***** $WM_CHANGECBCHAIN *****")

    ; If the next window is closing, repair the chain
    If $iwParam = $hNext Then
        $hNext = $ilParam
        ; Otherwise pass the message to the next viewer
    ElseIf $hNext <> 0 Then
        _SendMessage ($hNext, $WM_CHANGECBCHAIN, $iwParam, $ilParam, 0, "hwnd", "hwnd")
    EndIf
EndFunc   ;==>WM_CHANGECBCHAIN

; Handle $WM_DRAWCLIPBOARD messages
Func WM_DRAWCLIPBOARD($hWnd, $iMsg, $iwParam, $ilParam)
    If WinActive($hGUI) Then
        If $hNext <> 0 Then Return _SendMessage ($hNext, $WM_DRAWCLIPBOARD, $iwParam, $ilParam)
        Return
    EndIf
    
    MemoWrite(@TAB&"$hWnd="&$hWnd&" $iMsg="&$iMsg&" $iwParam: "&$iwParam&" $ilParam:"&$ilParam&@CRLF & _
    "$hGUI="&$hGUI&" $hNext="&$hNext&" GetOwner()="&_ClipBoard_GetOwner()&" GetViewer()="&_ClipBoard_GetViewer()&@CRLF)
    ; Display any text on clipboard
    MemoWrite(_ClipBoard_GetData ())

    ; Pass the message to the next viewer
    If $hNext <> 0 Then _SendMessage ($hNext, $WM_DRAWCLIPBOARD, $iwParam, $ilParam)
EndFunc   ;==>WM_DRAWCLIPBOARD

The above will already evade "Self recognition" and will not execute the ""content"" of the '$WM_DRAWCLIPBOARD' msg function...

However, i would like to know how can i pre'program it to EVADE other windows, specific ones... and not just SELF.

I've also done that by a stupid work-around, i'm using Program A to write on registry - 'Skip Capturing clip', then program A writes to clip, program B recognises the 'Skip Capturing clip' msg, changes it back to '' and that's it...

but i was thinking there is some other more sophisticated way of doing so... i guess not.

P.S - still can't realize why would u use SEND and CTRL for whatever u'r trying to do...

[ClipPut/Set_Data are not using CTRL+V !!!]

anyhow thanks for trying to help!!!

[u]My Au3 Scripts:[/u]____________(E)Lephant, A Share download manager (RS/MU etc)Http1.1 Console, The Ez Way!Internet Reconnection Automation Suite & A Macro Recording Tool.SK's Alarm Clock, Playing '.MP3 & .Wav' Files._________________Is GOD a mistake of the Humanity Or the Humanity is a mistake of GOD ?!

Link to comment
Share on other sites

sorry mate but i've tried what u've made... i don't quite get the point of it...

#include <ClipBoard.au3>
#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include <SendMessage.au3>

Opt('MustDeclareVars', 1)

Global $iMemo, $hGUI, $BUTT, $BUTT2, $hNext = 0

_Main()

Func _Main()
    ; Create GUI
    $hGUI = GUICreate("Clipboard", 600, 450)
    $iMemo = GUICtrlCreateEdit("", 2, 2, 596, 396, $WS_VSCROLL)
    GUICtrlSetFont($iMemo, 9, 400, 0, "Courier New")
    $BUTT = GUICtrlCreateButton("_ClipBoard_SetData",15,400, 50,20)
    $BUTT2 = GUICtrlCreateButton("ClipPut",75,400, 50,20)
    GUISetState()

    ; Initialize clipboard viewer
    $hNext = _ClipBoard_SetViewer ($hGUI)

    GUIRegisterMsg($WM_CHANGECBCHAIN, "WM_CHANGECBCHAIN")
    GUIRegisterMsg($WM_DRAWCLIPBOARD, "WM_DRAWCLIPBOARD")

    ; Loop until user exits
    Do
        Switch GUIGetMsg()
            Case $BUTT
                _ClipBoard_SetData ("************_ClipBoard_SetData************")
            Case $BUTT2
                ClipPut("(************ClipPut************")
        EndSwitch
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

    ; Shut down clipboard viewer
    _ClipBoard_ChangeChain ($hGUI, $hNext)
EndFunc   ;==>_Main

; Write message to memo
Func MemoWrite($sMessage = "")
    GUICtrlSetData($iMemo, GUICtrlRead($iMemo)& @CRLF&"_________________________________________" & @CRLF&$sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite

; Handle $WM_CHANGECBCHAIN messages
Func WM_CHANGECBCHAIN($hWnd, $iMsg, $iwParam, $ilParam)
    ; Show that message was received
    MemoWrite("***** $WM_CHANGECBCHAIN *****")

    ; If the next window is closing, repair the chain
    If $iwParam = $hNext Then
        $hNext = $ilParam
        ; Otherwise pass the message to the next viewer
    ElseIf $hNext <> 0 Then
        _SendMessage ($hNext, $WM_CHANGECBCHAIN, $iwParam, $ilParam, 0, "hwnd", "hwnd")
    EndIf
EndFunc   ;==>WM_CHANGECBCHAIN

; Handle $WM_DRAWCLIPBOARD messages
Func WM_DRAWCLIPBOARD($hWnd, $iMsg, $iwParam, $ilParam)
    If WinActive($hGUI) Then
        If $hNext <> 0 Then Return _SendMessage ($hNext, $WM_DRAWCLIPBOARD, $iwParam, $ilParam)
        Return
    EndIf
    
    MemoWrite(@TAB&"$hWnd="&$hWnd&" $iMsg="&$iMsg&" $iwParam: "&$iwParam&" $ilParam:"&$ilParam&@CRLF & _
    "$hGUI="&$hGUI&" $hNext="&$hNext&" GetOwner()="&_ClipBoard_GetOwner()&" GetViewer()="&_ClipBoard_GetViewer()&@CRLF)
    ; Display any text on clipboard
    MemoWrite(_ClipBoard_GetData ())

    ; Pass the message to the next viewer
    If $hNext <> 0 Then _SendMessage ($hNext, $WM_DRAWCLIPBOARD, $iwParam, $ilParam)
EndFunc   ;==>WM_DRAWCLIPBOARD

The above will already evade "Self recognition" and will not execute the ""content"" of the '$WM_DRAWCLIPBOARD' msg function...

However, i would like to know how can i pre'program it to EVADE other windows, specific ones... and not just SELF.

I've also done that by a stupid work-around, i'm using Program A to write on registry - 'Skip Capturing clip', then program A writes to clip, program B recognises the 'Skip Capturing clip' msg, changes it back to '' and that's it...

but i was thinking there is some other more sophisticated way of doing so... i guess not.

P.S - still can't realize why would u use SEND and CTRL for whatever u'r trying to do...

[ClipPut/Set_Data are not using CTRL+V !!!]

anyhow thanks for trying to help!!!

The point of my last post was to show a way to add the clipboard contents to the edit without using _ClipBoard_GetData which makes AutoIt crash on my PC and I thought was giving you problems as well. I don't see why Ctrl V doesn't do the same, the example I gave worked for me. The example was also to show how to set focus back to the previous window which I thought you wanted to do.

To evade certain windows doesn't _ClipBoard_GetOwner give you what you want?

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...