Clipboard Monitor

Subramaniam Karthik karsce at usa.net
Thu Apr 4 12:45:59 EST 2002


Hi, 
  I am writing a clipboard monitor for windows in python. my code looks
something like this.

class MyWindow:
    def __init__(self):
        message_map = {
            win32con.WM_DESTROY: self.OnDestroy,
            win32con.WM_DRAWCLIPBOARD: self.OnDrawClipboard,
            win32con.WM_CHANGECBCHAIN: self.OnChangeCBChain,
        }
        #   Register thw window class.
        wc = WNDCLASS()
        self.hinst = wc.hInstance = GetModuleHandle(None)
        . . .
        self.classAtom = RegisterClass(wc)      
        style = win32con.WS_OVERLAPPED | win32con.WS_SYSMENU
              style,0, 0, 150, 100,0, 0, self.hinst, None)
        self.hwnd = CreateWindow( self.classAtom, "Clipboard Monitor",  
              style,900, 50, 350, 200,0, 0, self.hinst, None)
        ShowWindow(self.hwnd,1)
        
        self.nextWnd = win32clipboard.SetClipboardViewer()

    def OnDestroy(self, hwnd, msg, wparam, lparam):
        win32clipboard.ChangeClipboardChain(self.hwnd, self.nextWnd)  
        DestroyWindow(self.hwnd)
        UnregisterClass(self.classAtom,GetModuleHandle
                             (None))                                
        PostQuitMessage(0)  #   Terminate the app.

    def OnChangeCBChain(self, hwnd, msg, wparam, lparam):
        SendMessage(self.nextWnd, msg, wparam, lparam)
        
    def OnDrawClipboard(self, hwnd, msg, wparam, lparam):
        SendMessage(self.nextWnd, msg, wparam, lparam)


def main():
    w = MyWindow()
    PumpMessages()

if __name__ == '__main__':
    main()

when i execute this program, i get the followinf error message.

File "C:\Program Files\karthik\Source files\test2.py", line 30, in __init__
    self.nextWnd = win32clipboard.SetClipboardViewer()
TypeError: SetClipboardViewer() takes exactly 1 argument (0 given)

Could anyone please tell me as to what i am doing wrong here?

Thanks

Karthik






More information about the Python-list mailing list