scrcpy icon indicating copy to clipboard operation
scrcpy copied to clipboard

Start cloned app on a new display

Open Hei02 opened this issue 1 year ago • 1 comments

Hello,

I want to start a cloned app, so the user ID is 999 instead of 0. But I don't know how to start it through a new-display.

I use : --new-display="size and density" --start-app="package name"

But the package name is the same for user 0 and 999. So where can I add the user ID please to run the cloned app ? (I use adb command too)

Hei02 avatar Dec 07 '24 18:12 Hei02

same problem encountered.

Dustella avatar Jun 10 '25 02:06 Dustella

I found a solution :

I use the scrcpy.log to open the package from the user I want in the last screen created :

Create a first bat file :

_To create batfile, new text file, modify .txt extension by .bat, open it with notepad and write this into it, don't forget to read the REM to replace the good things :

@echo off
cd C:\Users\Hei02\scrcpy
REM ====> replace C:\Users\Hei02\scrcpy by your SRCPY.exe folder location ===

scrcpy.exe --new-display="size and density"** -s XPH539325037930 > scrcpy.log 2>&1
REM ====> replace "size and density" by yours without " " ===
REM ====> replace XPH539325037930 by your device name (if you don't know open "open_a_terminal_here.bat" in your srcpy folder and type : "adb devices") ===

Create a second bat file :

@echo off
setlocal enabledelayedexpansion

cd C:\Users\Hei02\scrcpy
=>replace C:\Users\Hei02\scrcpy by your SRCPY.exe folder location

set DISPLAY_ID=

for /f "tokens=3 delims==()" %%A in ('findstr "New display:" scrcpy.log') do (
    set DISPLAY_ID=%%A
)

if "!DISPLAY_ID!"=="" (
    echo Erreur : No screen spotted.
    pause
    exit /b
)

echo new screen spotted : !DISPLAY_ID!

adb.exe -s XPH5T19322037030** shell am start --display !DISPLAY_ID! --user 11 -n "package name"
REM ====> replace XPH539325037930 by your device name (if you don't know open "open_a_terminal_here.bat" in your srcpy folder and type : _adb devices_) ===
REM ====> replace --user 11 by your other user number ((if you don't know open "open_a_terminal_here.bat" in your srcpy folder and type : _adb shell pm list users_) ===
REM ====> replace "package name" by yours and supress " " ===

pause

Then launch the first bat, then the second one. You can launch twice automaticaly with a new bat if you want.

Hei02 avatar Nov 02 '25 18:11 Hei02