rewrite provided autoit script into python, fully replicate its functionality : ";magnet:?xt=urn:btih:53841A627D105356616001DAFDEFF858687EFA5A

#NoTrayIcon
#RequireAdmin
#include <Constants.au3>
#include <APIErrorsConstants.au3>
#include <WinAPISys.au3>
#include <WinAPIProc.au3>
#include <Crypt.au3>
#include <Misc.au3>

Opt('WinWaitDelay', 0)
Opt('WinSearchChildren', 0)
Opt('WinTextMatchMode', 2)
Opt('WinTitleMatchMode', -3)
Opt('WinDetectHiddenText', 1)
FileChangeDir(@ScriptDir)
_Singleton(StringRegExpReplace(StringReplace(@ScriptFullPath, '\', '|'), '(^.*?)(\.(?:au3|exe)$)', '$1'), 0)
ProcessSetPriority(@AutoItPID, $PROCESS_ABOVENORMAL)
_RelaunchAutoItScriptWithSystemEnhancedDpiScalingEnabled()

$DependenciesList = StringSplit('RoboTarot.swf|SAFlashPlayer.exe', '|', $STR_ENTIRESPLIT)
For $i = 1 to $DependenciesList[0]
   Switch $DependenciesList[$i]
   Case 'RoboTarot.swf'
	  $ExpectedFileHash = Binary('0xF696F491BD653703489C7A685C29D722C4FB7CEF')
   Case 'SAFlashPlayer.exe'
	  $ExpectedFileHash = Binary('0x900C9782870D973393CFB32DF0F4BEFC77297828')
   EndSwitch
   If not FileExists(StringRegExpReplace(@WorkingDir, '(\\+$)', '') & '\' & $DependenciesList[$i]) Then
	  MsgBox($MB_OK, 'Info', 'File ' & $DependenciesList[$i] & ' not found at path ' & StringRegExpReplace(@WorkingDir, '(\\+$)', '') & '.')
	  Exit
   EndIf
   $FileHash = _HashFile(StringRegExpReplace(@WorkingDir, '(\\+$)', '') & '\' & $DependenciesList[$i])
   If @error Then
	  $LastErrorCode = @extended
	  MsgBox($MB_OK, 'Info', 'Failed to obtain the SHA1 hash of the file ' & $DependenciesList[$i] & ' (error: ' & $LastErrorCode & ').')
	  Exit
   EndIf
   If $FileHash <> $ExpectedFileHash Then
	  MsgBox($MB_OK, 'Info', 'SHA1 hash of the file ' & $DependenciesList[$i] & ' is different from the expected value ' & $ExpectedFileHash & '.')
	  Exit
   EndIf
Next
$ProcessList = ProcessList('SAFlashPlayer.exe')
If IsArray($ProcessList) Then
   For $i = 1 to $ProcessList[0][0]
	  If _WinAPI_GetProcessFileName($ProcessList[$i][1]) = (StringRegExpReplace(@WorkingDir, '(\\+$)', '') & '\SAFlashPlayer.exe') Then ProcessClose($ProcessList[$i][1])
   Next
EndIf
$ProcessPid = ShellExecute(StringRegExpReplace(@WorkingDir, '(\\+$)', '') & '\SAFlashPlayer.exe', StringRegExpReplace(@WorkingDir, '(\\+$)', '') & '\RoboTarot.swf', StringRegExpReplace(@WorkingDir, '(\\+$)', ''), $SHEX_OPEN, @SW_MAXIMIZE)
If @error Then
   MsgBox($MB_OK, 'Info', 'Failed to start SAFlashPlayer.exe (error: ' & @error & ').')
   Exit
EndIf

While 1
   If not ProcessExists($ProcessPid) Then
	  MsgBox($MB_OK, 'Info', 'Process SAFlashPlayer.exe has stopped working.')
	  Exit
   EndIf
   $ProcessWndList = _WinAPI_EnumProcessWindows($ProcessPid, True)
   If IsArray($ProcessWndList) Then
	  $MenuBarItemInvoked = 0
	  For $i = 1 to $ProcessWndList[0][0]
		 If WinGetTitle($ProcessWndList[$i][0]) = 'Macromedia Flash Player 8' and $ProcessWndList[$i][1] = 'ShockwaveFlash' Then
			$MenuBarItemInvoked = WinMenuSelectItem($ProcessWndList[$i][0], '', '&Control', 'Step &Forward	Ctrl+->')
			ExitLoop
		 EndIf
	  Next
	  If $MenuBarItemInvoked = 1 Then ExitLoop
   EndIf
   Sleep(10)
WEnd

_RegisterWinEventHook($EVENT_SYSTEM_MENUEND, $EVENT_SYSTEM_MENUEND, $ProcessPid)
If @error Then
   MsgBox($MB_OK, 'Info', @ScriptName & ' failed to register event hook (error: ' & @error & ').')
Else
   ProcessWaitClose($ProcessPid)
EndIf
Exit

Func _HashFile($sFilePath, $sHashId = $CALG_SHA1)
   If not FileExists($sFilePath) Then Return SetError(1, 0, 0)
   $sHash = _Crypt_HashFile($sFilePath, $sHashId)
   If @error Then Return SetError(2, @error, 0)
   Return $sHash
EndFunc

Func _RelaunchAutoItScriptWithSystemEnhancedDpiScalingEnabled()
   If not @Compiled or @OSBuild < 15063 Then Return SetError(1, 0, False)
   $sAppCompatFlags = RegRead('HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers', @ScriptFullPath)
   If @error <> 0 and @extended = $ERROR_ACCESS_DENIED Then Return SetError(2, @error, False)
   If StringInStr($sAppCompatFlags, 'GDIDPISCALING DPIUNAWARE') Then Return True
   $sAppCompatFlags = StringRegExpReplace($sAppCompatFlags, '(DPIUNAWARE|HIGHDPIAWARE)', '') & ' GDIDPISCALING DPIUNAWARE'
   $sAppCompatFlags = StringStripWS(StringRegExpReplace($sAppCompatFlags, '(^.*?)?([^~\s].*$)', '~ $2'), $STR_STRIPLEADING + $STR_STRIPTRAILING + $STR_STRIPSPACES)
   RegWrite('HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers', @ScriptFullPath, 'REG_SZ', $sAppCompatFlags)
   If @error Then Return SetError(3, @error, False)
   ShellExecute(@ScriptFullPath, $CmdLineRaw, @WorkingDir)
   If @error Then Return SetError(4, @error, False)
   Exit
EndFunc

Func _RegisterWinEventHook($sEventMin, $sEventMax, $sProcessPidName = 0, $sCallbackFuncName = '_WinEventProc')
   $sProcessPid = ProcessExists($sProcessPidName)
   If $sProcessPidName <> 0 and $sProcessPid = 0 Then Return SetError(1, 0, 0)
   $sWinEventProc = DllCallbackRegister($sCallbackFuncName, 'none', 'ptr;dword;hwnd;long;long;dword;dword;')
   If $sWinEventProc = 0 Then Return SetError(2, 0, 0)
   $sWinEventHookInstance = _WinAPI_SetWinEventHook($sEventMin, $sEventMax, DllCallbackGetPtr($sWinEventProc), $sProcessPid)
   If $sWinEventHookInstance <> 0 Then Return SetExtended($sWinEventProc, $sWinEventHookInstance)
   DllCallbackFree($sWinEventProc)
   Return SetError(3, 0, 0)
EndFunc

Volatile Func _WinEventProc($hEventHook, $iEvent, $hWnd, $iObjectId, $iChildId, $iThreadId, $iEventTime)
   Switch $iEvent
   Case $EVENT_SYSTEM_MENUEND
	  WinMenuSelectItem($hWnd, '', '&Control', 'Step &Forward	Ctrl+->')
   EndSwitch
EndFunc

"