rendered paste body# Echo client programimport socket, winamp, selectfrom ctypes import *user32 = windll.user32HOST = 'localhost' # The remote hostPORT = 8765 # The same port as used by the servers = socket.socket(socket.AF_INET, socket.SOCK_STREAM)s.connect((HOST, PORT))s.setblocking(0)class POINT(Structure): _fields_ = [ ("x", c_ulong), ("y", c_ulong), ]cursorPos = POINT()running = 0try: w = winamp.winamp() running = 1except: print 'Winamp not running.'while 1: ready_to_read, ready_to_write, in_error = select.select([s], [], [], 5) if s in ready_to_read: data = s.recv(1024) info = data.split(' ') repeat = info[1] button = info[2] remote = info[3] print 'Button', button, 'pressed on remote', remote if running == 1: if repeat == '00': print 'First repeat.' if button == 'pause': w.pause() print 'Winamp paused.' elif button == 'play': w.play() print 'Winamp playing.' elif button == 'stop': w.stop() print 'Winamp stopped.' elif button == 'next': w.next() print 'Winamp went to next track.' elif button == 'previous': w.prev() print 'Winamp went to previous track.' else: print 'No action taken.' if button == 'fastforward': w.forward() print 'Winamp forwarded.' elif button == 'rewind': w.rewind() print 'Winamp rewound.' elif button == 'volumeup': w.raisevol() print 'Winamp volume raised.' elif button == 'volumedown': w.lowervol() print 'Winamp volume lowered.' elif button == 'cup': user32.GetCursorPos(byref(cursorPos)) user32.SetCursorPos(cursorPos.x, cursorPos.y - 5) elif button == 'cdown': user32.GetCursorPos(byref(cursorPos)) user32.SetCursorPos(cursorPos.x, cursorPos.y + 5) elif button == 'cleft': user32.GetCursorPos(byref(cursorPos)) user32.SetCursorPos(cursorPos.x - 5, cursorPos.y) elif button == 'cright': user32.GetCursorPos(byref(cursorPos)) user32.SetCursorPos(cursorPos.x + 5, cursorPos.y) else: print 'No action taken.' prints.close()