Appendix ======== Python Equivalents of AutoHotkey Keywords ----------------------------------------- This section lists the relevant AHK keywords (Commands, Function, Directives, and Variables) and their Python counterparts. .. list-table:: :header-rows: 1 + - AHK Keyword - Python Implementation + - `#If `_ - :class:`ahkpy.HotkeyContext` + - `#IfWinActive `_ - ``ahkpy.windows.filter().active_window_context().hotkey()`` + - `#IfWinExist `_ - ``ahkpy.Window.filter().window_context().hotkey()`` + - `#Include `_ - `The import statement `_ + - `1, 2, 3, etc `_ - :data:`sys.argv` + - `A_AhkPath `_ - :data:`ahk.executable` + - `A_AppData `_ - ``os.getenv("APPDATA")`` + - `A_AppDataCommon `_ - ``os.getenv("ALLUSERSPROFILE")`` + - `A_ComputerName `_ - ``os.getenv("COMPUTERNAME")`` + - `A_DD `_ - ``datetime.datetime.now().day`` + - `A_DDD `_ - ``datetime.datetime.now().strftime("%a")`` + - `A_DDDD `_ - ``datetime.datetime.now().strftime("%A")`` + - `A_DefaultMouseSpeed `_ - :attr:`ahkpy.Settings.mouse_speed` + - `A_Hour `_ - ``datetime.datetime.now().hour`` + - `A_IconFile `_ - :attr:`ahkpy.TrayMenu.tray_icon_file` + - `A_IconHidden `_ - :attr:`ahkpy.TrayMenu.is_tray_icon_visible` + - `A_IconNumber `_ - :attr:`ahkpy.TrayMenu.tray_icon_number` + - `A_Is64bitOS `_ - :func:`platform.architecture` + - `A_MDay `_ - ``datetime.datetime.now().day`` + - `A_Min `_ - ``datetime.datetime.now().minute`` + - `A_MM `_ - ``datetime.datetime.now().month`` + - `A_MMM `_ - ``datetime.datetime.now().strftime("%b")`` + - `A_MMMM `_ - ``datetime.datetime.now().strftime("%B")`` + - `A_Mon `_ - ``datetime.datetime.now().month`` + - `A_MouseDelay `_ - :attr:`ahkpy.Settings.mouse_delay` + - `A_MouseDelayPlay `_ - :attr:`ahkpy.Settings.mouse_delay_play` + - `A_MSec `_ - ``datetime.datetime.now().microsecond / 1000`` + - `A_Now `_ - :meth:`datetime.datetime.now` + - `A_NowUTC `_ - :meth:`datetime.datetime.utcnow` + - `A_OSVersion `_ - :func:`platform.win32_ver` + - `A_ProgramFiles `_ - ``os.getenv("PROGRAMFILES")`` + - `A_PtrSize `_ - ``struct.calcsize("P") * 8`` + - `A_ScriptDir `_ - ``os.path.dirname(__file__)`` or ``pathlib.Path(__file__).parent`` + - `A_ScriptFullPath `_ - :data:`ahkpy.script_full_path` + - `A_ScriptHwnd `_ - ``ahkpy.all_windows.first(pid=os.getpid)`` + - `A_ScriptName `_ - ``__file__`` + - `A_Sec `_ - ``datetime.datetime.now().second`` + - `A_Space `_ - ``" "`` + - `A_Tab `_ - ``"\t"`` + - `A_Temp `_ - ``os.getenv("TEMP")`` + - `A_TickCount `_ - :func:`time.perf_counter` + - `A_TitleMatchMode `_ - :attr:`ahkpy.Windows.title_mode` + - `A_UserName `_ - ``os.getenv("USERNAME")`` + - `A_WDay `_ - ``(datetime.datetime.now().weekday() + 2) % 7`` + - `A_WinDir `_ - ``os.getenv("WINDIR")`` + - `A_WorkingDir `_ - :func:`os.getcwd` + - `A_YDay `_ - ``datetime.datetime.now().strftime("%j").lstrip("0")`` + - `A_Year `_ - ``datetime.datetime.now().year`` + - `A_YWeek `_ - ``datetime.datetime.now().strftime("%Y%U")`` + - `A_YYYY `_ - ``datetime.datetime.now().year`` + - `Abs() `_ - :func:`abs` + - `ACos() `_ - :func:`math.acos` + - `Asc() `_ - :func:`ord` + - `ASin() `_ - :func:`math.asin` + - `ATan() `_ - :func:`math.atan` + - `BlockInput `_ - :func:`ahkpy.block_input`, :func:`ahkpy.block_input_while_sending`, :func:`ahkpy.block_mouse_move` context managers + - `Ceil() `_ - :func:`math.ceil` + - `Chr() `_ - :func:`chr` + - `Click `_ - :func:`ahkpy.click`, also :func:`~ahkpy.right_click`, :func:`~ahkpy.double_click`, :func:`~ahkpy.mouse_press`, :func:`~ahkpy.mouse_release`, :func:`~ahkpy.mouse_scroll`, :func:`~ahkpy.mouse_move` + - `Clipboard `_ - :func:`ahkpy.get_clipboard` and :func:`ahkpy.set_clipboard` + - `ClipWait `_ - :func:`ahkpy.wait_clipboard` + - `ComSpec `_ - ``os.getenv("COMSPEC")`` + - `Control, Check `_ - :meth:`ahkpy.Control.check`, also try setting :attr:`ahkpy.Control.is_checked` property + - `Control, Choose `_ - :meth:`ahkpy.Control.choose_item_index` + - `Control, ChooseString `_ - :meth:`ahkpy.Control.choose_item` + - `Control, Disable `_ - :meth:`ahkpy.Control.disable() `, also try setting :attr:`ahkpy.Control.is_enabled` property + - `Control, EditPaste `_ - :meth:`ahkpy.Control.paste` + - `Control, Enable `_ - :meth:`ahkpy.Control.enable() `, also try setting :attr:`ahkpy.Control.is_enabled ` property + - `Control, ExStyle `_ - :attr:`ahkpy.Control.ex_style ` + - `Control, Hide `_ - :meth:`ahkpy.Control.hide() `, also try setting :attr:`ahkpy.Control.is_visible ` property + - `Control, Show `_ - :meth:`ahkpy.Control.show() `, also try setting :attr:`ahkpy.Control.is_visible ` property + - `Control, Style `_ - :attr:`ahkpy.Control.style ` + - `Control, Uncheck `_ - :meth:`ahkpy.Control.uncheck`, also try setting :attr:`ahkpy.Control.is_checked` property + - `ControlFocus `_ - :meth:`ahkpy.Control.focus` + - `ControlGet, Checked `_ - :attr:`ahkpy.Control.is_checked` + - `ControlGet, Choice `_ - :attr:`ahkpy.Control.list_choice`, also :attr:`ahkpy.Control.list_choice_index` + - `ControlGet, CurrentCol `_ - :attr:`ahkpy.Control.current_column` + - `ControlGet, CurrentLine `_ - :attr:`ahkpy.Control.current_line_number` + - `ControlGet, Enabled `_ - :attr:`ahkpy.Control.is_enabled ` + - `ControlGet, ExStyle `_ - :attr:`ahkpy.Control.ex_style ` + - `ControlGet, FindString `_ - :meth:`ahkpy.Control.list_item_index` + - `ControlGet, Hwnd `_ - :attr:`ahkpy.Control.id` + - `ControlGet, Line `_ - :meth:`ahkpy.Control.get_line` + - `ControlGet, LineCount `_ - :attr:`ahkpy.Control.line_count` + - `ControlGet, List `_ - :attr:`ahkpy.Control.list_items`, also see :attr:`ahkpy.Control.selected_list_items`, :attr:`ahkpy.Control.focused_list_item`, :meth:`ahkpy.Control.get_list_items`, :attr:`ahkpy.Control.list_item_count`, :attr:`ahkpy.Control.selected_list_item_count`, :attr:`ahkpy.Control.focused_list_item_index`, :attr:`ahkpy.Control.list_view_column_count` + - `ControlGet, Selected `_ - :meth:`ahkpy.Control.selected_text` + - `ControlGet, Style `_ - :attr:`ahkpy.Control.style ` + - `ControlGet, Visible `_ - :attr:`ahkpy.Control.is_visible ` + - `ControlGetFocus `_ - :meth:`ahkpy.Window.get_focused_control` + - `ControlGetPos `_ - :attr:`ahkpy.Control.rect `, also :attr:`position `, :attr:`size `, :attr:`x `, :attr:`y `, :attr:`width `, :attr:`height ` properties + - `ControlGetText `_ - :attr:`ahkpy.Control.text` + - `ControlMove `_ - ``Window.get_control(class_name).rect = ...``, also try setting :class:`ahkpy.Control`'s :attr:`x `, :attr:`y `, :attr:`width `, :attr:`height ` properties + - `ControlSend `_ - :func:`ahkpy.window.BaseWindow.send` + - `ControlSendRaw `_ - ``ahkpy.Window.get_control(class_name).send("{Raw}...")`` + - `ControlSetText `_ - :attr:`ahkpy.Control.text` + - `Cos() `_ - :func:`math.cos` + - `DetectHiddenText `_ - :meth:`ahkpy.Windows.exclude_hidden_text` + - `DetectHiddenWindows `_ - :data:`ahkpy.all_windows` + - `DllCall() `_ - :mod:`ctypes` + - `EnvGet `_ - :data:`os.environ` or :func:`os.getenv` + - `EnvSet `_ - :data:`os.environ` or :func:`os.putenv` + - `ExitApp `_ - :func:`sys.exit` + - `Exp() `_ - :func:`math.exp` + - `FileAppend `_ - ``open().write()`` + - `FileCopy `_ - :func:`glob.glob` with :func:`shutil.copy` or :func:`shutil.copytree` + - `FileCopyDir `_ - :func:`glob.glob` with :func:`shutil.copy` or :func:`shutil.copytree` + - `FileCreateDir `_ - :func:`os.mkdir` or :func:`os.makedirs` + - `FileDelete `_ - :func:`os.remove` + - `FileEncoding `_ - ``open(encoding="...")`` + - `FileGetSize `_ - :func:`os.path.getsize` + - `FileGetTime `_ - :func:`os.path.getatime`, :func:`os.path.getmtime`, or :func:`os.path.getctime` + - `FileMove `_ - :func:`shutil.move` + - `FileMoveDir `_ - :func:`shutil.move` + - `FileOpen() `_ - :func:`open` + - `FileRead `_ - ``open().read()`` + - `FileReadLine `_ - ``open().readline()`` + - `FileRemoveDir `_ - :func:`shutil.rmtree` + - `FileSetTime `_ - Can set *atime* and *mtime* with :func:`os.utime`, cannot set *ctime* + - `Floor() `_ - :func:`math.floor` + - `Format() `_ - `f-strings `_ or :meth:`str.format` + - `FormatTime `_ - :func:`format` or :meth:`datetime.datetime.strftime` + - `GetKeyName() `_ - :func:`ahkpy.get_key_name` + - `GetKeySC() `_ - :func:`ahkpy.get_key_sc` + - `GetKeyState `_ - :func:`ahkpy.is_key_pressed` or :func:`ahkpy.is_key_pressed_logical` + - `GetKeyState() `_ - :func:`ahkpy.is_key_pressed` or :func:`ahkpy.is_key_pressed_logical`, :func:`ahkpy.get_caps_lock_state`, :func:`ahkpy.get_num_lock_state`, :func:`ahkpy.get_scroll_lock_state`, :func:`ahkpy.get_insert_state` + - `GetKeyVK() `_ - :func:`ahkpy.get_key_vk` + - `GroupClose `_ - :meth:`ahkpy.Windows.close_all` + - `Hotkey `_ - :func:`ahkpy.hotkey` + - `Hotstring() `_ - :func:`ahkpy.hotstring` + - `IfMsgBox `_ - ``if ahkpy.message_box(...) == "...": ...`` + - `IniDelete `_ - :mod:`configparser` module + - `IniRead `_ - :mod:`configparser` module + - `IniWrite `_ - :mod:`configparser` module + - `InStr() `_ - ``"..." in str`` or :meth:`str.find` + - `KeyWait `_ - :func:`ahkpy.wait_key_pressed` or :func:`ahkpy.wait_key_released` + - `Ln() `_ - :func:`math.log` + - `Log() `_ - :func:`math.log10` + - `Loop `_ - `The for statement `_ + - `Loop, Files `_ - :func:`os.scandir` or :func:`os.listdir` + - `Loop, Read `_ - ``open().read()`` + - `Loop, Reg `_ - :mod:`winreg` module + - `LTrim() `_ - :meth:`str.lstrip` + - `Mod() `_ - The ``%`` (modulo) operator + - `Menu, $, Add `_ - :meth:`ahkpy.Menu.add` + - `Menu, $, Insert `_ - :meth:`ahkpy.Menu.insert` + - `Menu, $, Delete `_ - :meth:`ahkpy.Menu.delete_item`, :meth:`ahkpy.Menu.delete_menu` + - `Menu, $, DeleteAll `_ - :meth:`ahkpy.Menu.delete_all_items` + - `Menu, $, Rename `_ - :meth:`ahkpy.Menu.rename` + - `Menu, $, Check `_ - :meth:`ahkpy.Menu.check` + - `Menu, $, Uncheck `_ - :meth:`ahkpy.Menu.uncheck` + - `Menu, $, ToggleCheck `_ - :meth:`ahkpy.Menu.toggle_checked` + - `Menu, $, Enable `_ - :meth:`ahkpy.Menu.enable` + - `Menu, $, Disable `_ - :meth:`ahkpy.Menu.disable` + - `Menu, $, ToggleEnable `_ - :meth:`ahkpy.Menu.toggle_enabled` + - `Menu, $, Default `_ - :meth:`ahkpy.Menu.set_default` + - `Menu, $, NoDefault `_ - :meth:`ahkpy.Menu.remove_default` + - `Menu, $, Icon `_ - :meth:`ahkpy.Menu.set_icon` + - `Menu, $, NoIcon `_ - :meth:`ahkpy.Menu.remove_icon` + - `Menu, $, Show `_ - :meth:`ahkpy.Menu.show` + - `Menu, $, Color `_ - :meth:`ahkpy.Menu.set_color` + - `Menu, Tray, Icon `_ - :meth:`ahkpy.TrayMenu.set_tray_icon`, :meth:`ahkpy.TrayMenu.toggle_tray_icon`, :meth:`ahkpy.TrayMenu.show_tray_icon` + - `Menu, Tray, NoIcon `_ - :meth:`ahkpy.TrayMenu.hide_tray_icon` + - `Menu, Tray, Tip `_ - :attr:`ahkpy.TrayMenu.tip` + - `Menu, Tray, Click `_ - :meth:`ahkpy.TrayMenu.set_clicks` + - `MouseClick `_ - :func:`ahkpy.click`, also :func:`~ahkpy.right_click`, :func:`~ahkpy.double_click`, :func:`~ahkpy.mouse_press`, :func:`~ahkpy.mouse_release`, :func:`~ahkpy.mouse_scroll`, :func:`~ahkpy.mouse_move` + - `MouseClickDrag `_ - Use :func:`ahkpy.mouse_press`, :func:`ahkpy.mouse_move`, and :func:`ahkpy.mouse_release` + - `MouseGetPos `_ - :func:`ahkpy.get_mouse_pos`, :func:`~ahkpy.get_window_under_mouse`, :func:`~ahkpy.get_control_under_mouse` + - `MouseMove `_ - :func:`ahkpy.mouse_move` + - `NumGet() `_ - :func:`struct.unpack` + - `NumPut() `_ - :func:`struct.pack` + - `OnClipboardChange `_ - :func:`ahkpy.on_clipboard_change` + - `OnMessage() `_ - :func:`ahkpy.on_message` + - `OutputDebug `_ - :func:`ahkpy.output_debug` + - `PostMessage `_ - :meth:`ahkpy.window.BaseWindow.post_message` + - `Process `_ - `psutil `_ package + - `ProgramFiles `_ - ``os.getenv("PROGRAMFILES")`` + - `Random `_ - :mod:`random` module + - `RegDelete `_ - :mod:`winreg` module + - `RegExMatch() `_ - :func:`re.search` + - `RegExReplace() `_ - :func:`re.sub` + - `RegisterCallback() `_ - :func:`ctypes.CFUNCTYPE` + - `RegRead `_ - :mod:`winreg` module + - `RegWrite `_ - :mod:`winreg` module + - `Reload `_ - :func:`ahkpy.restart` + - `Round() `_ - :func:`round` + - `RTrim() `_ - :meth:`str.rstrip` + - `Run `_ - :class:`subprocess.Popen` + - `RunWait `_ - :func:`subprocess.run` + - `Send `_ - :func:`ahkpy.send` + - `SendEvent `_ - :func:`ahkpy.send_event` + - `SendInput `_ - :func:`ahkpy.send_input` + - `SendLevel `_ - Set the *level* argument in :func:`ahkpy.send` or via :attr:`ahkpy.Settings.send_level` + - `SendMessage `_ - :meth:`ahkpy.window.BaseWindow.send_message` + - `SendMode `_ - Set the *mode* argument in :func:`ahkpy.send` or via :attr:`ahkpy.Settings.send_mode` + - `SendPlay `_ - :func:`ahkpy.send_play` + - `SetCapslockState `_ - :func:`ahkpy.set_caps_lock_state` + - `SetControlDelay `_ - :attr:`ahkpy.Settings.control_delay` + - `SetDefaultMouseSpeed `_ - Set the *speed* argument in :func:`ahkpy.mouse_move` or via :attr:`ahkpy.Settings.mouse_speed` + - `SetKeyDelay `_ - :attr:`ahkpy.Settings.key_delay` + - `SetMouseDelay `_ - Set the *delay* argument in :func:`ahkpy.click` or via :attr:`ahkpy.Settings.mouse_delay` and :attr:`ahkpy.Settings.mouse_delay_play` + - `SetNumLockState `_ - :func:`ahkpy.set_num_lock_state` + - `SetScrollLockState `_ - :func:`ahkpy.set_scroll_lock_state` + - `SetTimer `_ - :func:`ahkpy.set_timer` + - `SetTitleMatchMode `_ - Set the *match* argument in :meth:`ahkpy.Windows.filter` + - `SetWinDelay `_ - :attr:`ahkpy.Settings.win_delay` + - `SetWorkingDir `_ - :func:`os.chdir` + - `Sin() `_ - :func:`math.sin` + - `Sleep `_ - :func:`ahkpy.sleep` + - `Sort `_ - :func:`sorted` or :meth:`list.sort` + - `SplitPath `_ - :func:`os.path.basename`, :func:`os.path.dirname`, :func:`os.path.splitext`, :func:`os.path.splitdrive` + - `Sqrt() `_ - :func:`math.sqrt` + - `StatusBarGetText `_ - :meth:`ahkpy.Window.get_status_bar_text` + - `StatusBarWait `_ - :meth:`ahkpy.Window.wait_status_bar` + - `StrGet() `_ - :meth:`bytes.decode` or :mod:`struct` module + - `StringGetPos `_ - ``"..." in str`` or :meth:`str.find` + - `StringLeft `_ - ``str[:count]`` + - `StringLen `_ - ``len(str)`` + - `StringLower `_ - :meth:`str.lower` + - `StringMid `_ - ``str[left:left+count]`` + - `StringReplace `_ - :meth:`str.replace` + - `StringRight `_ - ``str[-count:]`` + - `StringSplit() `_ - :meth:`str.split` + - `StringTrimLeft `_ - ``str[count:]`` + - `StringTrimRight `_ - ``str[:-count]`` + - `StringUpper `_ - :meth:`str.upper` + - `StrLen() `_ - :func:`len` + - `StrPut() `_ - :meth:`str.encode` or :mod:`struct` module + - `StrSplit() `_ - :meth:`str.split` + - `SubStr() `_ - ``str[start:start+len]`` + - `Suspend `_ - :func:`ahkpy.suspend`, :func:`ahkpy.resume`, :func:`ahkpy.toggle_suspend` + - `Tan() `_ - :func:`math.tan` + - `ToolTip `_ - :class:`ahkpy.ToolTip` + - `Transform `_ - :func:`html.escape` + - `Trim() `_ - :meth:`str.strip` + - `UrlDownloadToFile `_ - :func:`urllib.request.urlopen` or `requests `_ package + - `WinActivate `_ - :meth:`ahkpy.Window.activate` + - `WinActivateBottom `_ - ``ahkpy.Windows.last().activate()`` + - `WinActive() `_ - :meth:`ahkpy.Windows.get_active` + - `WinClose `_ - :func:`ahkpy.Window.close` + - `WinExist() `_ - :meth:`ahkpy.Windows.first` + - `WinGet, ControlList `_ - :attr:`ahkpy.Window.control_classes` + - `WinGet, ControlListHwnd `_ - :attr:`ahkpy.Window.controls` + - `WinGet, Count `_ - ``len(ahkpy.windows.filter())`` + - `WinGet, ExStyle `_ - :attr:`ahkpy.Window.ex_style ` + - `WinGet, ID `_ - :attr:`ahkpy.Window.id` + - `WinGet, IDLast `_ - ``ahkpy.windows.last().id`` + - `WinGet, List `_ - ``list(ahkpy.windows.filter())`` + - `WinGet, MinMax `_ - :attr:`ahkpy.Window.is_minimized`, :attr:`ahkpy.Window.is_maximized`, :attr:`ahkpy.Window.is_restored` + - `WinGet, PID `_ - :attr:`ahkpy.Window.pid ` + - `WinGet, ProcessName `_ - :attr:`ahkpy.Window.process_name ` + - `WinGet, ProcessPath `_ - :attr:`ahkpy.Window.process_path ` + - `WinGet, Style `_ - :attr:`ahkpy.Window.style ` + - `WinGet, TransColor `_ - :attr:`ahkpy.Window.transparent_color` + - `WinGet, Transparent `_ - :attr:`ahkpy.Window.opacity` + - `WinGetClass `_ - :attr:`ahkpy.Window.class_name ` + - `WinGetPos `_ - :attr:`ahkpy.Window.rect `, also :attr:`position `, :attr:`size `, :attr:`x `, :attr:`y `, :attr:`width `, :attr:`height ` properties + - `WinGetText `_ - :attr:`ahkpy.Window.text` + - `WinGetTitle `_ - :attr:`ahkpy.Window.title` + - `WinHide `_ - :meth:`ahkpy.Window.hide() ` + - `WinKill `_ - :meth:`ahkpy.Window.kill` + - `WinMaximize `_ - :meth:`ahkpy.Window.maximize` + - `WinMinimize `_ - :meth:`ahkpy.Window.minimize` + - `WinMinimizeAll `_ - :meth:`ahkpy.Windows.minimize_all` + - `WinMove `_ - :meth:`ahkpy.Window.move() ` + - `WinRestore `_ - :meth:`ahkpy.Window.restore` + - `WinSetTitle `_ - :attr:`ahkpy.Window.title` + - `WinShow `_ - :meth:`ahkpy.Window.show() ` + - `WinWait `_ - :meth:`ahkpy.Windows.wait` + - `WinWaitActive `_ - :meth:`ahkpy.Windows.wait_active` + - `WinWaitClose `_ - :meth:`ahkpy.Windows.wait_close` + - `WinWaitNotActive `_ - :meth:`ahkpy.Window.wait_inactive`