feat: enhance swipe and back navigation logic

- Adjusted configuration for reset after swipes to 10 seconds and added action to go back.
- Updated flow control to skip back action if a recent reset was triggered within 5 seconds.
- Implemented a mechanism to enable back navigation when consecutive misses reach a threshold.
- Added GUI options to enable or disable back navigation on misses, ensuring consistency with user settings.
- Introduced new diagnostic tools for runtime flag checks and screenshot diagnostics.
- Created PowerShell scripts for restoring Start Menu shortcuts and performing system health checks.
- Added tests for swipe operations and back navigation to validate new logic.
This commit is contained in:
Your Name committed 2026-01-06 16:55:00 +08:00
1 parent 0c3a763d63
commit dcded08796
19 files changed
+936 -22

No files matched your search

+19
View File
@@ -0,0 +1,19 @@
from douyin.core.douyin_fudai import fudai_analyse
from douyin.utils import douyin_config
def main():
a = fudai_analyse()
print('Before load:')
print(' enable_back_on_misses attr ->', getattr(a, 'enable_back_on_misses', None))
print(' reset_after_swipes_action attr ->', getattr(a, 'reset_after_swipes_action', None))
print(' fudai_exit_after_misses attr ->', getattr(a, 'fudai_exit_after_misses', None))
# load from config
douyin_config.ConfigManager.load_config_from_file(a)
print('\nAfter load_config_from_file:')
print(' enable_back_on_misses ->', getattr(a, 'enable_back_on_misses', None))
print(' reset_after_swipes_action ->', getattr(a, 'reset_after_swipes_action', None))
print(' fudai_exit_after_misses ->', getattr(a, 'fudai_exit_after_misses', None))
if __name__ == '__main__':
main()
+87
View File
@@ -0,0 +1,87 @@
[CmdletBinding()]
param(
[Parameter(Mandatory=$true)]
[string]$IsoPath,
[int]$Index = 0,
[switch]$NoUnmount
)
$ErrorActionPreference = 'Stop'
function Write-Section([string]$title) {
Write-Host ""
Write-Host "=== $title ==="
}
function Test-IsAdmin {
$principal = New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent())
return $principal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
}
if (!(Test-IsAdmin)) {
throw 'Please run this script as Administrator.'
}
$isoFull = (Resolve-Path $IsoPath).Path
if (!(Test-Path -LiteralPath $isoFull)) {
throw "ISO not found: $isoFull"
}
Write-Section 'Mount ISO'
Write-Host "ISO: $isoFull"
$disk = Mount-DiskImage -ImagePath $isoFull -PassThru
Start-Sleep -Seconds 1
$vol = ($disk | Get-Volume | Select-Object -First 1)
if ($null -eq $vol -or [string]::IsNullOrWhiteSpace($vol.DriveLetter)) {
throw 'Failed to get mounted ISO drive letter.'
}
$drive = ($vol.DriveLetter + ':')
Write-Host "Mounted drive: $drive"
try {
Write-Section 'Locate install.wim/install.esd'
$wim = Join-Path $drive 'sources\install.wim'
$esd = Join-Path $drive 'sources\install.esd'
$imagePath = $null
if (Test-Path -LiteralPath $wim) { $imagePath = $wim }
elseif (Test-Path -LiteralPath $esd) { $imagePath = $esd }
else { throw 'install.wim/install.esd not found under sources\\' }
Write-Host "Image: $imagePath"
Write-Section 'Show available indexes'
dism /English /Get-WimInfo /WimFile:"$imagePath"
if ($Index -le 0) {
Write-Host "\nIndex is 0: please re-run with -Index <number> matching your edition (e.g. Pro/Home)."
return
}
Write-Section 'DISM RestoreHealth (from ISO source)'
Write-Host "Using Index: $Index"
$sourceArg = if ($imagePath.ToLowerInvariant().EndsWith('.wim')) {
"wim:$imagePath:$Index"
} else {
"esd:$imagePath:$Index"
}
dism /Online /Cleanup-Image /RestoreHealth /Source:$sourceArg /LimitAccess
Write-Section 'SFC Scannow'
sfc /scannow
Write-Host '\nDone. Reboot recommended.'
}
finally {
if (-not $NoUnmount) {
Write-Section 'Unmount ISO'
Dismount-DiskImage -ImagePath $isoFull -ErrorAction SilentlyContinue
} else {
Write-Host 'NoUnmount set; ISO left mounted.'
}
}
+226
View File
@@ -0,0 +1,226 @@
[CmdletBinding()]
param(
[ValidateSet('Auto','Diagnose','FixShortcuts','RestartShell','ReregisterAppx')]
[string]$Mode = 'Auto'
)
$ErrorActionPreference = 'Stop'
function Write-Section([string]$title) {
Write-Host ""
Write-Host "=== $title ==="
}
function Test-IsAdmin {
$principal = New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent())
return $principal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
}
function Get-UserSid {
return ([System.Security.Principal.WindowsIdentity]::GetCurrent()).User.Value
}
function Get-ProfileImagePathFromRegistry([string]$sid) {
$key = "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList\$sid"
if (Test-Path $key) {
return (Get-ItemProperty $key).ProfileImagePath
}
return $null
}
function Get-LnkCount([string]$path) {
if (!(Test-Path $path)) { return -1 }
return (Get-ChildItem -LiteralPath $path -Recurse -Filter '*.lnk' -ErrorAction SilentlyContinue | Measure-Object).Count
}
function Ensure-Directory([string]$path) {
if (!(Test-Path $path)) {
New-Item -ItemType Directory -Path $path -Force | Out-Null
}
}
function Get-StartMenuPaths {
$programsUser = Join-Path $env:APPDATA 'Microsoft\Windows\Start Menu\Programs'
$programsCommon = Join-Path $env:ProgramData 'Microsoft\Windows\Start Menu\Programs'
return [pscustomobject]@{
ProgramsUser = $programsUser
ProgramsCommon = $programsCommon
}
}
function Find-CandidateProgramsUserPaths([string]$currentProgramsUser) {
$candidates = @()
$user = [Environment]::UserName
$roots = @('C:\Users', 'D:\Users', 'E:\Users', 'C:\Windows.old\Users')
foreach ($root in $roots) {
if (!(Test-Path $root)) { continue }
Get-ChildItem -LiteralPath $root -Directory -ErrorAction SilentlyContinue | ForEach-Object {
$candidate = Join-Path $_.FullName 'AppData\Roaming\Microsoft\Windows\Start Menu\Programs'
if ($candidate -ine $currentProgramsUser -and (Test-Path -LiteralPath $candidate -ErrorAction SilentlyContinue)) {
$count = Get-LnkCount $candidate
$candidates += [pscustomobject]@{ Path = $candidate; LnkCount = $count }
}
}
}
$candidates | Sort-Object LnkCount -Descending | Select-Object -First 10
}
function Backup-Folder([string]$sourcePath, [string]$backupRoot) {
if (!(Test-Path $sourcePath)) { return $null }
Ensure-Directory $backupRoot
$leaf = Split-Path $sourcePath -Leaf
$backupPath = Join-Path $backupRoot $leaf
Ensure-Directory $backupPath
Copy-Item -LiteralPath $sourcePath -Destination $backupPath -Recurse -Force -ErrorAction SilentlyContinue
return $backupPath
}
function Copy-Shortcuts([string]$fromPath, [string]$toPath) {
Ensure-Directory $toPath
$items = Get-ChildItem -LiteralPath $fromPath -Force -ErrorAction SilentlyContinue
foreach ($item in $items) {
if ($item.Name -ieq 'desktop.ini') { continue }
Copy-Item -LiteralPath $item.FullName -Destination $toPath -Recurse -Force -ErrorAction SilentlyContinue
}
}
function Restart-Shell {
Write-Section 'Restart Shell/Start Menu'
$procs = @('StartMenuExperienceHost','ShellExperienceHost')
foreach ($p in $procs) {
Get-Process -Name $p -ErrorAction SilentlyContinue | Stop-Process -Force -ErrorAction SilentlyContinue
}
Get-Process -Name explorer -ErrorAction SilentlyContinue | Stop-Process -Force -ErrorAction SilentlyContinue
Start-Sleep -Milliseconds 600
Start-Process explorer.exe
Write-Host 'Explorer restarted.'
}
function Reregister-AppxCurrentUser {
Write-Section 'Re-register AppX (Current User)'
Get-AppxPackage | ForEach-Object {
$manifest = Join-Path $_.InstallLocation 'AppxManifest.xml'
if (Test-Path $manifest) {
try {
Add-AppxPackage -DisableDevelopmentMode -Register $manifest -ErrorAction Stop | Out-Null
} catch {
# Keep going; many packages will throw benign errors
}
}
}
Write-Host 'AppX re-register done (current user).'
}
function Diagnose {
$sid = Get-UserSid
$profileImagePath = Get-ProfileImagePathFromRegistry $sid
$paths = Get-StartMenuPaths
Write-Section 'Diagnose'
Write-Host "Admin: $(Test-IsAdmin)"
Write-Host "User: $([Environment]::UserName)"
Write-Host "SID: $sid"
Write-Host "ProfileImagePath(HKLM): $profileImagePath"
Write-Host "USERPROFILE: $env:USERPROFILE"
Write-Host "APPDATA: $env:APPDATA"
Write-Host "ProgramData: $env:ProgramData"
Write-Host "ProgramsUser: $($paths.ProgramsUser)"
Write-Host "ProgramsCommon: $($paths.ProgramsCommon)"
$userExists = Test-Path $paths.ProgramsUser
$commonExists = Test-Path $paths.ProgramsCommon
Write-Host "User.Exists=$userExists LnkCount=$(Get-LnkCount $paths.ProgramsUser)"
Write-Host "Common.Exists=$commonExists LnkCount=$(Get-LnkCount $paths.ProgramsCommon)"
Write-Section 'Top-level items (first 20)'
if ($userExists) {
Write-Host "[User] $($paths.ProgramsUser)"
Get-ChildItem -LiteralPath $paths.ProgramsUser -Force -ErrorAction SilentlyContinue | Select-Object -First 20 Name | ForEach-Object { $_.Name }
} else {
Write-Host "[User] (missing)"
}
if ($commonExists) {
Write-Host "[Common] $($paths.ProgramsCommon)"
Get-ChildItem -LiteralPath $paths.ProgramsCommon -Force -ErrorAction SilentlyContinue | Select-Object -First 20 Name | ForEach-Object { $_.Name }
} else {
Write-Host "[Common] (missing)"
}
return [pscustomobject]@{
Sid = $sid
ProfileImagePath = $profileImagePath
ProgramsUser = $paths.ProgramsUser
ProgramsCommon = $paths.ProgramsCommon
UserLnkCount = Get-LnkCount $paths.ProgramsUser
CommonLnkCount = Get-LnkCount $paths.ProgramsCommon
}
}
function Fix-Shortcuts {
Write-Section 'Fix Start Menu Shortcuts'
$diag = Diagnose
Ensure-Directory $diag.ProgramsUser
Ensure-Directory $diag.ProgramsCommon
$now = Get-Date -Format 'yyyyMMdd_HHmmss'
$desktop = [Environment]::GetFolderPath('Desktop')
$backupRoot = Join-Path $desktop "StartMenuBackup_$now"
Write-Host "BackupRoot: $backupRoot"
$backupUser = Backup-Folder $diag.ProgramsUser $backupRoot
$backupCommon = Backup-Folder $diag.ProgramsCommon $backupRoot
Write-Host "BackupUser: $backupUser"
Write-Host "BackupCommon: $backupCommon"
$candidates = Find-CandidateProgramsUserPaths $diag.ProgramsUser
if (!$candidates -or $candidates.Count -eq 0) {
Write-Host 'No candidate old Programs paths found under C:\Users/D:\Users/E:\Users.'
return
}
Write-Section 'Candidate old ProgramsUser paths'
$candidates | Select-Object -First 5 | Format-Table -AutoSize
$best = $candidates | Select-Object -First 1
if ($best.LnkCount -le $diag.UserLnkCount) {
Write-Host "Current ProgramsUser already has >= shortcuts than best candidate. (Current=$($diag.UserLnkCount), Best=$($best.LnkCount))"
return
}
Write-Host "Copying shortcuts from: $($best.Path)"
Write-Host "To (current user programs): $($diag.ProgramsUser)"
Copy-Shortcuts $best.Path $diag.ProgramsUser
Write-Host "AfterCopy User LnkCount=$(Get-LnkCount $diag.ProgramsUser)"
}
switch ($Mode) {
'Diagnose' { Diagnose | Out-Null; break }
'FixShortcuts' { Fix-Shortcuts; break }
'RestartShell' { Restart-Shell; break }
'ReregisterAppx' { Reregister-AppxCurrentUser; break }
'Auto' {
$diag = Diagnose
Fix-Shortcuts
Restart-Shell
# If Start Menu is still missing many Store apps, user can run this explicitly.
Write-Host "\nTip: If Store apps are still missing, run: .\\tools\\fix_start_menu_win11.ps1 -Mode ReregisterAppx"
break
}
}
+81
View File
@@ -0,0 +1,81 @@
[CmdletBinding()]
param(
[switch]$SkipDism,
[switch]$SkipSfc,
[switch]$SkipAppx
)
$ErrorActionPreference = 'Stop'
function Write-Section([string]$title) {
Write-Host ""
Write-Host "=== $title ==="
}
function Test-IsAdmin {
$principal = New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent())
return $principal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
}
$now = Get-Date -Format 'yyyyMMdd_HHmmss'
$logPath = Join-Path ([Environment]::GetFolderPath('Desktop')) "StartMenuFix_Admin_$now.log"
"StartMenuFix Admin started: $(Get-Date)" | Out-File -FilePath $logPath -Encoding UTF8
"Running as admin: $(Test-IsAdmin)" | Out-File -FilePath $logPath -Append -Encoding UTF8
if (!(Test-IsAdmin)) {
"ERROR: This script must be run as Administrator." | Out-File -FilePath $logPath -Append -Encoding UTF8
throw 'This script must be run as Administrator.'
}
Write-Host "Log: $logPath"
try {
if (-not $SkipDism) {
Write-Section 'DISM RestoreHealth'
"DISM start: $(Get-Date)" | Out-File -FilePath $logPath -Append -Encoding UTF8
DISM /Online /Cleanup-Image /RestoreHealth | Out-File -FilePath $logPath -Append -Encoding UTF8
"DISM end: $(Get-Date)" | Out-File -FilePath $logPath -Append -Encoding UTF8
}
if (-not $SkipSfc) {
Write-Section 'SFC Scannow'
"SFC start: $(Get-Date)" | Out-File -FilePath $logPath -Append -Encoding UTF8
sfc /scannow | Out-File -FilePath $logPath -Append -Encoding UTF8
"SFC end: $(Get-Date)" | Out-File -FilePath $logPath -Append -Encoding UTF8
}
if (-not $SkipAppx) {
Write-Section 'Re-register AppX (All Users)'
"AppX re-register start: $(Get-Date)" | Out-File -FilePath $logPath -Append -Encoding UTF8
Get-AppxPackage -AllUsers | ForEach-Object {
$manifest = Join-Path $_.InstallLocation 'AppxManifest.xml'
if (Test-Path $manifest) {
try {
Add-AppxPackage -DisableDevelopmentMode -Register $manifest -ErrorAction Stop | Out-Null
} catch {
# Keep going; capture error into log for diagnostics
"WARN: $($_.Name) - $($_.Exception.Message)" | Out-File -FilePath $logPath -Append -Encoding UTF8
}
}
}
"AppX re-register end: $(Get-Date)" | Out-File -FilePath $logPath -Append -Encoding UTF8
}
Write-Section 'Restart Explorer'
"Restart explorer: $(Get-Date)" | Out-File -FilePath $logPath -Append -Encoding UTF8
Get-Process -Name StartMenuExperienceHost -ErrorAction SilentlyContinue | Stop-Process -Force -ErrorAction SilentlyContinue
Get-Process -Name ShellExperienceHost -ErrorAction SilentlyContinue | Stop-Process -Force -ErrorAction SilentlyContinue
Get-Process -Name explorer -ErrorAction SilentlyContinue | Stop-Process -Force -ErrorAction SilentlyContinue
Start-Sleep -Milliseconds 600
Start-Process explorer.exe
"DONE: $(Get-Date)" | Out-File -FilePath $logPath -Append -Encoding UTF8
Write-Host 'Done. Explorer restarted.'
Write-Host "Log saved: $logPath"
} catch {
"FATAL: $($_.Exception.Message)" | Out-File -FilePath $logPath -Append -Encoding UTF8
throw
}
@@ -0,0 +1,107 @@
[CmdletBinding()]
param(
[switch]$WhatIf
)
$ErrorActionPreference = 'Stop'
function Write-Section([string]$title) {
Write-Host ""
Write-Host "=== $title ==="
}
$programsUser = Join-Path $env:APPDATA 'Microsoft\Windows\Start Menu\Programs'
$programsCommon = Join-Path $env:ProgramData 'Microsoft\Windows\Start Menu\Programs'
Write-Section 'Targets'
Write-Host "ProgramsUser: $programsUser"
Write-Host "ProgramsCommon: $programsCommon"
Write-Host "WhatIf: $WhatIf"
Write-Section 'Enumerate Recycle Bin'
$shell = New-Object -ComObject Shell.Application
$recycle = $shell.Namespace(0xA)
if ($null -eq $recycle) {
throw 'Failed to open Recycle Bin namespace.'
}
$items = @($recycle.Items())
Write-Host "RecycleBin items: $($items.Count)"
function Get-DeletedFrom($item) {
try { return $item.ExtendedProperty('System.Recycle.DeletedFrom') } catch { return $null }
}
function Get-OriginalName($item) {
try { return $item.Name } catch { return $null }
}
function Find-RestoreVerb($item) {
try {
$verbs = @($item.Verbs())
foreach ($v in $verbs) {
$name = ($v.Name -as [string])
if ([string]::IsNullOrWhiteSpace($name)) { continue }
$n = $name.Replace('&','').Trim()
if ($n -match '(?i)restore' -or $n -match '还原') {
return $n
}
}
} catch { }
return $null
}
$matches = @()
foreach ($it in $items) {
$deletedFrom = Get-DeletedFrom $it
$name = Get-OriginalName $it
if ([string]::IsNullOrWhiteSpace($name)) { continue }
$isLnk = $name.ToLowerInvariant().EndsWith('.lnk')
if (!$isLnk) { continue }
if ($deletedFrom -and (
$deletedFrom -like "$programsUser*" -or
$deletedFrom -like "$programsCommon*" -or
$deletedFrom -like '*\\Microsoft\\Windows\\Start Menu\\Programs*'
)) {
$matches += [pscustomobject]@{ Name = $name; DeletedFrom = $deletedFrom; Item = $it }
}
}
Write-Section 'Matches'
Write-Host "Matching .lnk from Start Menu Programs: $($matches.Count)"
$matches | Select-Object -First 50 Name,DeletedFrom | Format-List
if ($matches.Count -eq 0) {
Write-Host 'No matching shortcuts found in Recycle Bin.'
exit 0
}
if ($WhatIf) {
Write-Host 'WhatIf set; not restoring.'
exit 0
}
Write-Section 'Restore'
$restored = 0
$skipped = 0
foreach ($m in $matches) {
$it = $m.Item
$verb = Find-RestoreVerb $it
if ([string]::IsNullOrWhiteSpace($verb)) {
$skipped++
continue
}
try {
$it.InvokeVerb($verb)
$restored++
} catch {
$skipped++
}
}
Write-Host "Restored: $restored"
Write-Host "Skipped: $skipped"
Write-Host 'Tip: If restore succeeded, restart Explorer / Start menu.'
+19
View File
@@ -0,0 +1,19 @@
from Underlying_Operations import underlying_operations
import time
op = underlying_operations()
# try to trigger several screenshots
for i in range(8):
print(f"Triggering screenshot #{i+1}")
ok = op.get_screenshot(device_id="DUMMY_DEVICE", path="pic", use_service=False)
print("result:", ok)
time.sleep(0.6)
print('\n--- Log snippet ---')
try:
with open('logs/screenshot_calls.log', 'r', encoding='utf-8') as f:
lines = f.read().splitlines()
for ln in lines[-120:]:
print(ln)
except Exception as e:
print('Could not read log:', e)
+41
View File
@@ -0,0 +1,41 @@
from douyin.core.douyin_fudai import fudai_analyse
from douyin.handlers import douyin_swipe_ops
class DummyOp:
def swipe(self, device_id, sx, sy, ex, ey, duration_ms):
# minimal output
print(f"swipe: device={device_id} from=({sx},{sy}) to=({ex},{ey}) dur={duration_ms}")
def click_back(self, device_id=None):
print(f"click_back called, device={device_id}")
def main():
a = fudai_analyse()
a.operation = DummyOp()
a.device_id = "DUMMY"
# use config default of 10 to simulate ten swipes
a.fudai_exit_after_misses = int(getattr(a, 'fudai_exit_after_misses', 10) or 10)
print('fudai_exit_after_misses =', a.fudai_exit_after_misses)
# ensure counter starts at 0
a._consecutive_no_fudai_count = 0
for i in range(1, 11):
print(f"\n-- swipe #{i} --")
douyin_swipe_ops.swipe_up_switch_live(a)
# simulate not finding fudai -> increment counter
a._consecutive_no_fudai_count = int(getattr(a, '_consecutive_no_fudai_count', 0)) + 1
print('consecutive_no_fudai_count =', a._consecutive_no_fudai_count)
if a._consecutive_no_fudai_count >= a.fudai_exit_after_misses:
print('threshold reached, invoking back')
try:
a.operation.click_back(a.device_id)
except Exception:
print('click_back failed')
# reset counter as real logic would
a._consecutive_no_fudai_count = 0
break
else:
print('\nNo back triggered after 10 swipes')
if __name__ == '__main__':
main()
+69
View File
@@ -0,0 +1,69 @@
from douyin.core.douyin_fudai import fudai_analyse
from douyin.utils import douyin_config
class DummyOp:
def __init__(self):
self.clicked_back = False
self.clicked_coord = None
def click_back(self, device_id=None):
print("DummyOp.click_back called, device_id=", device_id)
self.clicked_back = True
def click(self, device_id, x, y):
print(f"DummyOp.click called at ({x},{y}), device_id={device_id}")
self.clicked_coord = (x,y)
def simulate():
a = fudai_analyse()
# use dummy op to avoid real adb
a.operation = DummyOp()
# ensure config loads (reads config/config.json)
a.load_config()
print("config enable_back_on_misses ->", getattr(a, "enable_back_on_misses", None))
# 快速验证:强制设置阈值为 1(触发返回键)
a.fudai_exit_after_misses = 1
print("(test override) fudai_exit_after_misses ->", a.fudai_exit_after_misses)
# simulate "not found" path logic
cur = int(getattr(a, "_consecutive_no_fudai_count", 0) or 0)
print("initial consecutive count ->", cur)
cur += 1
setattr(a, "_consecutive_no_fudai_count", cur)
print("after increment ->", cur)
threshold = int(getattr(a, "fudai_exit_after_misses", 0) or 0) or None
if threshold is None or threshold <= 0:
threshold = 30
if threshold and cur >= threshold:
print("threshold reached: cur=", cur, "threshold=", threshold)
enabled = getattr(a, "enable_back_on_misses", None)
print("enable_back_on_misses attribute ->", enabled)
if enabled is None:
# try load from file
try:
douyin_config.ConfigManager.load_config_from_file(a)
enabled = bool(getattr(a, "enable_back_on_misses", True))
except Exception:
enabled = True
print("final enabled ->", enabled)
if enabled:
try:
a.operation.click_back(a.device_id)
except Exception:
try:
# fallback coord click
rx = int(getattr(a, "resolution_ratio_x", 1080) or 1080)
ry = int(getattr(a, "resolution_ratio_y", 2400) or 2400)
back_x = int(50 * rx / 1080)
back_y = int(50 * ry / 2400)
a.operation.click(a.device_id, back_x, back_y)
except Exception:
print("both click_back and click fallback failed")
else:
print("enabled is False; skipping back click")
else:
print("threshold not reached: cur=", cur, "threshold=", threshold)
if __name__ == '__main__':
simulate()
+25
View File
@@ -0,0 +1,25 @@
from douyin.handlers.douyin_swipe_handler import SwipeHandler
class DummyOp:
def click_back(self, device_id=None):
print('DummyOp.click_back called, device_id=', device_id)
def delay(self, s):
pass
class DummyAnalyser:
def __init__(self):
self.operation = DummyOp()
self.device_id = 'DUMMY'
self._swipe_times = 5
self.reset_after_swipes_enabled = True
self.reset_after_swipes = 5
self.reset_after_swipes_action = 'back'
self.resolution_ratio_x = 1080
self.resolution_ratio_y = 2400
self.room_pos = 3
if __name__ == '__main__':
a = DummyAnalyser()
print('Before maybe_reset, _swipe_times=', a._swipe_times, 'action=', a.reset_after_swipes_action)
SwipeHandler.maybe_reset_after_swipes(a)
print('After maybe_reset, _swipe_times=', getattr(a, '_swipe_times', None), 'room_pos=', getattr(a, 'room_pos', None))
+23
View File
@@ -0,0 +1,23 @@
from douyin.handlers import douyin_swipe_ops
from douyin.core.douyin_fudai import fudai_analyse
class DummyOp:
def _adb(self):
# Return path to non-existing adb to force fallback
return "adb"
def swipe(self, device_id, sx, sy, ex, ey, duration_ms):
print(f"DummyOp.swipe called device={device_id} from ({sx},{sy}) to ({ex},{ey}) duration={duration_ms}")
def simulate_once(i:int):
a = fudai_analyse()
a.operation = DummyOp()
a.device_id = f"DUMMY{i}"
a.resolution_ratio_x = 1080
a.resolution_ratio_y = 2400
print(f"--- simulate swipe #{i} ---")
douyin_swipe_ops.swipe_up_switch_live(a)
if __name__ == '__main__':
for i in range(1, 11):
simulate_once(i)