diff --git a/piker/brokers/ib/_util.py b/piker/brokers/ib/_util.py index 2941284a..cb3affc7 100644 --- a/piker/brokers/ib/_util.py +++ b/piker/brokers/ib/_util.py @@ -197,15 +197,20 @@ async def vnc_click_hack( ) -> None: ''' Reset the data or network connection for the VNC attached - ib gateway using magic combos. + ib-gateway using a (magic) keybinding combo. ''' try: - import asyncvnc + from pyvnc import ( + AsyncVNCClient, + VNCConfig, + Point, + MOUSE_BUTTON_LEFT, + ) except ModuleNotFoundError: log.warning( "In order to leverage `piker`'s built-in data reset hacks, install " - "the `asyncvnc` project: https://github.com/barneygale/asyncvnc" + "the `pyvnc` project: https://github.com/regulad/pyvnc.git" ) return @@ -216,24 +221,27 @@ async def vnc_click_hack( 'connection': 'r' }[reset_type] - async with asyncvnc.connect( - host, - port=port, - - # TODO: doesn't work? - # see, https://github.com/barneygale/asyncvnc/issues/7 - password='doggy', - - ) as client: - - # move to middle of screen - # 640x1800 - client.mouse.move( - x=500, - y=500, + with tractor.devx.open_crash_handler(): + client = await AsyncVNCClient.connect( + VNCConfig( + host=host, + port=port, + password='doggy', + ) ) - client.mouse.click() - client.keyboard.press('Ctrl', 'Alt', key) # keys are stacked + async with client: + # move to middle of screen + # 640x1800 + await client.move( + Point( + 500, + 500, + ) + ) + # ensure the ib-gw window is active + await client.click(MOUSE_BUTTON_LEFT) + # send the hotkeys combo B) + await client.press('Ctrl', 'Alt', key) # keys are stacked def i3ipc_fin_wins_titled(