-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Description
Currently in src/api.py we have code such as
def press_key(key, verbose=True):
try:
if verbose:
logging.info(f"Pressing key {key}")
WINDOW.send(key, blocking=True, press_duration=30)
except AttributeError:
logging.info(f"Window not active. {key} was not sent to the client.")
# duration in seconds
def hold_key(x, duration):
try:
logging.info(f"Holding {x} for {duration} seconds")
WINDOW.send(x, blocking=True, press_duration=duration * 1000)
except AttributeError:
logging.info(f"Window not active. {x} was not sent to the client.")Note the WINDOW.send(press_duration=30). If I look into site-packages/ahk/_sync/window.py where this send function is defined for the Window class I can see the current function body for ahk 1.8.1:
# fmt: off
@overload
def control_send(self, keys: str, control: str = '', title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None) -> None: ...
@overload
def control_send(self, keys: str, control: str = '', title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, blocking: Literal[False]) -> FutureResult[None]: ...
@overload
def control_send(self, keys: str, control: str = '', title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, blocking: Literal[True]) -> None: ...
@overload
def control_send(self, keys: str, control: str = '', title: str = '', text: str = '', exclude_title: str = '', exclude_text: str = '', *, title_match_mode: Optional[TitleMatchMode] = None, detect_hidden_windows: Optional[bool] = None, blocking: bool = True) -> Union[None, FutureResult[None]]: ...
# fmt: on
def control_send(
self,
keys: str,
control: str = '',
title: str = '',
text: str = '',
exclude_title: str = '',
exclude_text: str = '',
*,
title_match_mode: Optional[TitleMatchMode] = None,
detect_hidden_windows: Optional[bool] = None,
blocking: bool = True,
) -> Union[None, FutureResult[None]]:Note that press_duration is completely absent.
However in site-packages/ahk/_sync/engine.py there is class AHK(Generic[T_AHKVersion]) which has send() which has key_press_duration. Perhaps this should be migrated to as I suspect that the current argument overload is completely functionless and will always only use the default key press duration.
Current use of the functions press_key(key, verbose=True) and hold_key(x, duration) is:
async def reshade(ctx, author, args):
api.press_key("{F9}")
##async def scores(ctx, author, args):
## api.hold_key(config.get_bind("+scores"), 4.5)
async def reload(ctx, author, args):
api.hold_key(config.get_bind("+scores"), 0.0001)
##async def speclist(ctx, author, args):
## msg = f"Watchable players:" \
## f" {serverstate.STATE.get_specable_players()} " \
## f"-- Do ?spec # to spectate a specific player, where # is their id number."
## await ctx.channel.send(msg)
## api.hold_key(config.get_bind("+scores"), 4.5)
##
## if len(serverstate.STATE.nospec_ids) > 0:
## nospec_msg = f"NOTE: " \
## f"The following player{'s' if len(serverstate.STATE.nospec_ids) > 1 else ''} " \
## f"{'have' if len(serverstate.STATE.nospec_ids) > 1 else 'has'} disabled spec permissions: " \
## f"{serverstate.STATE.get_nospec_players()}"
## await ctx.channel.send(nospec_msg)Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels