Aug-15-2020, 03:04 AM
I followed a tutorial in setting up a script to where users in a chat could choose the outcome of playing a game. Think Twitchplayspokemon. Now I followed everything and had it working on my main PC with Windows 10 and Python 3.8.5. I then tested it on my older Windows Vista PC running Python 2.7.18. Now this is where the error comes in that I get. This error appears in the "autohotkey.py". I will post the python and arrow message I receive below. Remember, everything is the same on my main PC this works on, so I'm not sure if there is a syntax difference in the 2.7.18 version of Python. The traceback is below the Python.
[python]
from collections import deque
from ahk.mouse import MouseMixin
from ahk.window import Window, WindowMixin
from ahk.script import ScriptEngine
from ahk.screen import ScreenMixin
from ahk.keyboard import KeyboardMixin
from ahk.sound import SoundMixin
from ahk.registery import RegisteryMixin
class AHK(
WindowMixin, MouseMixin, KeyboardMixin,
ScreenMixin, SoundMixin, RegisteryMixin
):
"""
Inherits its methods from the following classes:
| :py:class:
| :py:class:
| :py:class:
| :py:class:
| :py:class:
| :py:class:
"""
pass
class ActionChain(AHK):
"""
Reusable action chain to execute various actions in order
"""
def __init__(self, *args, **kwargs):
self._actions = deque()
super().__init__(*args, **kwargs)
def run_script(self, *args, **kwargs):
"""
override run_script to defer to queue
"""
kwargs['decode'] = False #
self._actions.appendleft((args, kwargs))
def perform(self):
results = []
while self._actions:
args, kwargs = self._actions.pop()
results.append(super().run_script(*args, **kwargs))
return results
def sleep(self, n):
"""
:param n: how long (in seconds) to sleep
:return:
"""
n = n * 1000 # convert to milliseconds
script = self.render_template('base.ahk', body=f'Sleep {n}', directives={'#Persistent', })
self.run_script(script)
[python]
The traceback I get is below:
Traceback (most recent call last):
File "C:\Python27\Lib\site-packages\ahk\autohotkey.py", line 2, in <module>
from ahk.mouse import MouseMixin
File "C:\Python27\lib\site-packages\ahk\__init__.py", line 1, in <module>
from ahk.autohotkey import AHK, ActionChain
File "C:\Python27\lib\site-packages\ahk\autohotkey.py", line 2, in <module>
from ahk.mouse import MouseMixin
File "C:\Python27\lib\site-packages\ahk\mouse.py", line 38
button = f'X{button-3}'
^
SyntaxError: invalid syntax
[Finished in 0.3s with exit code 1]
[shell_cmd: python -u "C:\Python27\Lib\site-packages\ahk\autohotkey.py"]
[dir: C:\Python27\Lib\site-packages\ahk]
[path: C:\Python27]
[python]
from collections import deque
from ahk.mouse import MouseMixin
from ahk.window import Window, WindowMixin
from ahk.script import ScriptEngine
from ahk.screen import ScreenMixin
from ahk.keyboard import KeyboardMixin
from ahk.sound import SoundMixin
from ahk.registery import RegisteryMixin
class AHK(
WindowMixin, MouseMixin, KeyboardMixin,
ScreenMixin, SoundMixin, RegisteryMixin
):
"""
Inherits its methods from the following classes:
| :py:class:
ahk.window.WindowMixin
| :py:class:
ahk.mouse.MouseMixin
| :py:class:
ahk.keyboard.KeyboardMixin
| :py:class:
ahk.screen.ScreenMixin
| :py:class:
ahk.sound.SoundMixin
| :py:class:
ahk.registery.RegisteryMixin
"""
pass
class ActionChain(AHK):
"""
Reusable action chain to execute various actions in order
"""
def __init__(self, *args, **kwargs):
self._actions = deque()
super().__init__(*args, **kwargs)
def run_script(self, *args, **kwargs):
"""
override run_script to defer to queue
"""
kwargs['decode'] = False #
self._actions.appendleft((args, kwargs))
def perform(self):
results = []
while self._actions:
args, kwargs = self._actions.pop()
results.append(super().run_script(*args, **kwargs))
return results
def sleep(self, n):
"""
:param n: how long (in seconds) to sleep
:return:
"""
n = n * 1000 # convert to milliseconds
script = self.render_template('base.ahk', body=f'Sleep {n}', directives={'#Persistent', })
self.run_script(script)
[python]
The traceback I get is below:
Traceback (most recent call last):
File "C:\Python27\Lib\site-packages\ahk\autohotkey.py", line 2, in <module>
from ahk.mouse import MouseMixin
File "C:\Python27\lib\site-packages\ahk\__init__.py", line 1, in <module>
from ahk.autohotkey import AHK, ActionChain
File "C:\Python27\lib\site-packages\ahk\autohotkey.py", line 2, in <module>
from ahk.mouse import MouseMixin
File "C:\Python27\lib\site-packages\ahk\mouse.py", line 38
button = f'X{button-3}'
^
SyntaxError: invalid syntax
[Finished in 0.3s with exit code 1]
[shell_cmd: python -u "C:\Python27\Lib\site-packages\ahk\autohotkey.py"]
[dir: C:\Python27\Lib\site-packages\ahk]
[path: C:\Python27]