I came up with this script because there are folks that like to use the mouse from a remote. as an example. the Pulse Eight plugin. This allows for nice smooth operation of the mouse.
Be sure to open the MouseMove script and read the directions at the top
Code: Select all
<?xml version="1.0" encoding="UTF-8" ?>
<EventGhost Version="WIP-2018.05.25-17.43.19">
<Folder Name="Move Mouse" XML_Guid="{9B208B86-41A2-4A86-9B73-E4E2D1EA9AA0}" Expanded="True">
<Macro Name="MoveMouse" XML_Guid="{ACFB7EC5-5153-4207-AFD6-135ACD401456}" Expanded="True">
<Event Name="Test.Up" XML_Guid="{249B84AD-021A-48A2-9C46-616D9E3E494A}" />
<Event Name="Test.Down" XML_Guid="{249B84AD-021A-48A2-9C46-616D9E3E494A}" />
<Event Name="Test.Left" XML_Guid="{249B84AD-021A-48A2-9C46-616D9E3E494A}" />
<Event Name="Test.Right" XML_Guid="{249B84AD-021A-48A2-9C46-616D9E3E494A}" />
<Action Name="MoveMouse" XML_Guid="{FEDF7E5D-AA77-45B0-BD12-01A48CF72CC9}">
EventGhost.PythonScript(u'# These Values you can change\n# ---------------------\nSTART_SPEED = 150 # inital speed\nMAX_SPEED = 7000 # i think you got this one\nACCELERATION = 7 # ""\nTIMEOUT = 50 # milliseconds\n# above is a timeout period. add one of the direction key events to the Get Timeout macro and hold the key down for several seconds. after 5 seconds the value you need to set tis to will be printed in the log\n# --------------------\n\n\ndirections = dict(\n Up=0.0,\n Right=90.0,\n Down=180.0,\n Left=270.0\n \n)\n\nimport threading\nimport time\n\nstart_time = time.time()\n\ndef do(up_func, event, evt):\n eg.Print(\'Moving Mouse: Direction \' + event.split(\'.\')[-1])\n \n while not evt.isSet():\n if eg.event.string != event:\n if event.rsplit(\'.\', 1)[0] != eg.event.string.rsplit(\'.\', 1)[0]:\n up_func()\n break\n \n if time.time() - start_time >= float(TIMEOUT) / 1000.0:\n up_func[0]()\n break\n evt.wait(0.001)\n thread.pop(0)\n\ntry:\n if thread:\n new_direction = eg.event.string.split(\'.\')[-1]\n new_direction = directions[new_direction]\n if new_direction != direction:\n stop_event.set()\n stop_event = threading.Event()\n eg.plugins.Mouse.GoDirection(new_direction, START_SPEED, MAX_SPEED, ACCELERATION, False)\n thread += [\n threading.Thread(\n target=do,\n args=(eg.event.upFuncList.pop(), eg.event.string, stop_event)\n )\n ]\n thread[-1].daemon = True\n thread[-1].start()\n \n else:\n direction = eg.event.string.split(\'.\')[-1]\n direction = directions[direction]\n stop_event = threading.Event()\n eg.plugins.Mouse.GoDirection(direction, START_SPEED, MAX_SPEED, ACCELERATION, False)\n thread += [\n threading.Thread(\n target=do,\n args=(eg.event.upFuncList.pop(), eg.event.string, stop_event)\n )\n ]\n thread[-1].daemon = True\n thread[-1].start()\n \n \nexcept NameError:\n direction = eg.event.string.split(\'.\')[-1]\n direction = directions[direction]\n stop_event = threading.Event()\n eg.plugins.Mouse.GoDirection(direction, START_SPEED, MAX_SPEED, ACCELERATION, False)\n thread = [\n threading.Thread(\n target=do,\n args=(eg.event.upFuncList.pop(), eg.event.string, stop_event)\n )\n ]\n thread[0].daemon = True\n thread[0].start()\n\n\n')
</Action>
</Macro>
<Macro Name="Test Script" XML_Guid="{53E6BD27-9C62-48E9-907E-3945F43350AA}" Expanded="True">
<Action Name="RUN THIS TO SEE MOUSE MOVE" XML_Guid="{8950BE00-9E5A-467C-AE40-337730C9FED7}">
EventGhost.PythonScript(u"import time\nimport threading\n\n\ndef do():\n for i in range(120):\n \n if 60 > i > 30 :\n eg.TriggerEvent(prefix='Test', suffix='Right')\n elif 90 > i > 60:\n eg.TriggerEvent(prefix='Test', suffix='Down')\n elif 120 > i > 90:\n eg.TriggerEvent(prefix='Test', suffix='Left')\n else:\n eg.TriggerEvent(prefix='Test', suffix='Up')\n \n time.sleep(0.045)\nthreading.Thread(target=do).start()")
</Action>
</Macro>
<Macro Name="Get Timeout" XML_Guid="{BFD7A369-0B98-4F58-A2EE-A1BA12B86BC1}" Expanded="True">
<Action Name="ADD DIRECTION BUTTON EVENT AND HOLD BUTTON FOR 3 SECONDS" XML_Guid="{E022C56C-A09C-4BCD-9717-19BED95CDF1C}">
EventGhost.PythonScript(u'import time\nimport threading\n\n\ndef do():\n global thread\n event = threading.Event()\n event.wait(5)\n print int(timeout)\n event.wait(2)\n thread = None\n\ntry:\n if thread is None:\n raise NameError\n \n end = time.time()\n timeout = max(timeout, (end - start) * 1000)\n start = end\n\nexcept NameError:\n timeout = 0\n thread = threading.Thread(target=do)\n start = time.time()\n thread.start()\n \n\n ')
</Action>
</Macro>
</Folder>
</EventGhost>