-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.bat
245 lines (220 loc) · 5.51 KB
/
script.bat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
@echo off
REM Change to working directory
cd /D "%~dp0\files"
REM Set current version
set /p vernow=<version.txt
REM By default, we assume that this is not our first launch.
set firstLaunch=0
echo -------------------------------
echo Screen mirroring script
echo v%vernow%
echo -------------------------------
echo.
echo Checking for updates...
curl --silent -o version2.txt https://raw.githubusercontent.com/rtd1250/mirrorscript/main/files/version.txt
if exist version2.txt (
set /p vernew=<version2.txt
goto compare
) else (
echo.
echo Updates can't be checked. Please check your internet connection.
pause
goto adb
)
:compare
if %vernow% LSS %vernew% (
echo.
echo New version %vernew% available. Download?
echo 1 for yes, 2 for no.
) else (
echo.
echo Up to date.
del version2.txt
goto adb
)
set /p choiced="Type your choice: "
if %choiced%==1 (
del version.txt
rename version2.txt version.txt
curl -o ..\script.bat https://raw.githubusercontent.com/rtd1250/mirrorscript/main/script.bat
exit
) else (
del version2.txt
)
:adb
echo.
if exist scrcpy-win64-v1.25.zip (
echo scrcpy already downloaded, moving on.
) else (
REM If scrcpy is not downloaded, chances are that this is our first launch
set firstLaunch=1
echo Downloading scrcpy...
curl -L -o scrcpy-win64-v1.25.zip https://github.com/Genymobile/scrcpy/releases/download/v1.25/scrcpy-win64-v1.25.zip
if not exist scrcpy-win64-v1.25.zip (
cls
color 4F
echo -------------------------------
echo Screen mirroring script
echo v%vernow%
echo -------------------------------
echo.
curl -L -o scrcpy-win64-v1.25.zip https://github.com/Genymobile/scrcpy/releases/download/v1.25/scrcpy-win64-v1.25.zip
echo.
echo Error: Dependencies can't be downloaded. Please check your internet connection.
pause
exit 0 )
echo Unpacking scrcpy...
tar -xf scrcpy-win64-v1.25.zip --strip-components=1
)
if exist sndcpy-v1.1.zip (
echo sndcpy already downloaded, moving on.
) else (
echo Downloading sndcpy...
curl -L -o sndcpy-v1.1.zip https://github.com/rom1v/sndcpy/releases/download/v1.1/sndcpy-v1.1.zip
if not exist sndcpy-v1.1.zip (
cls
color 4F
echo -------------------------------
echo Screen mirroring script
echo v%vernow%
echo -------------------------------
echo.
curl -L -o sndcpy-v1.1.zip https://github.com/rom1v/sndcpy/releases/download/v1.1/sndcpy-v1.1.zip
echo.
echo Error: Dependencies can't be downloaded. Please check your internet connection.
pause
exit 0 )
echo Unpacking sndcpy...
tar -xf sndcpy-v1.1.zip
)
echo.
echo Some checks...
REM Kill processes associated with scrcpy and sndcpy
tasklist /fi "ImageName eq scrcpy.exe" 2>NUL | find "scrcpy.exe">NUL
if %ERRORLEVEL%==0 (
taskkill /IM scrcpy.exe
echo Stopped scrcpy
)
tasklist /fi "ImageName eq vlc.exe" 2>NUL | find "vlc.exe">NUL
if %ERRORLEVEL%==0 (
taskkill /F /IM vlc.exe
echo Stopped VLC
)
tasklist /fi "ImageName eq adb.exe" 2>NUL | find "adb.exe">NUL
if %ERRORLEVEL%==0 (
adb disconnect
adb kill-server
echo Stopped ADB
)
REM Check if VLC is installed
set VLC="C:\Program Files\VideoLAN\VLC\vlc.exe"
if exist %VLC% ( goto main )
cls
color 1F
echo -------------------------------
echo Screen mirroring script
echo v%vernow%
echo -------------------------------
echo.
echo Warning - You do not seem to have VLC Media Player installed.
echo It's required for sound playback.
echo If you don't want to use sound capture, feel free to skip this message.
echo Do you want to download it?
echo.
set /p choicev="1 for Yes, 2 for Skip: "
if %choicev%==1 ( start "" https://www.videolan.org/vlc/ )
:main
adb start-server
cls
color 1f
echo -------------------------------
echo Screen mirroring script
echo v%vernow%
echo -------------------------------
echo.
if %firstLaunch%==1 (
echo Welcome!
echo If you are using this tool for the first time, make sure to:
echo 1. Unlock your phone
echo 2. Connect it using USB
echo 3. Accept the pop-up on the phone with "Remember this PC" ticked
echo 4. Press any key to continue
) else (
echo Plug in your phone now and press any key to continue.
)
echo.
pause
cls
echo -------------------------------
echo Screen mirroring script
echo v%vernow%
echo -------------------------------
echo.
echo 1. Screen mirroring
echo 2. Screen and sound mirroring
echo.
set /p sound="Type your choice here: "
cls
echo -------------------------------
echo Screen mirroring script
echo v%vernow%
echo -------------------------------
echo.
echo 1. USB
echo 2. Network
echo.
set /p mode="Type your choice here: "
cls
echo -------------------------------
echo Screen mirroring script
echo v%vernow%
echo -------------------------------
echo.
echo Resolution to pass to scrcpy? (-m parameter)
echo Leave empty if unsure.
echo.
set /p res="Max size: "
if %mode%==1 goto usb
if %sound%==2 ( continue ) else ( goto wifi )
cls
echo -------------------------------
echo Screen mirroring script
echo v%vernow%
echo -------------------------------
echo.
echo After you see the device's screen, return here to enable audio capture.
echo.
pause
:wifi
cls
echo Launching scrcpy!
if [%res%] == [] (
start scrcpy --tcpip
) else (
start scrcpy --tcpip -m %res%
)
if %sound%==2 (
echo.
echo Unplug USB, and press any key for sound capture.
pause
color 0f
echo Launching sndcpy!
start sndcpy.bat
)
goto end
:usb
cls
color 0f
echo Launching scrcpy!
if [%res%] == [] (
start scrcpy
) else (
start scrcpy -m %res%
)
if %sound%==2 (
echo Launching sndcpy!
start sndcpy.bat
)
goto end
:end
exit