AdriaGual / marvel-snap-bot

A computer vision bot made with OpenCV and ADB.
93 stars 25 forks source link

ADB Port on Bluestacks 5 #47

Open TiemN opened 1 year ago

TiemN commented 1 year ago

Bluestacks 5 no longer defaults the ADB port to 5555 and randomize it on startup. Everytime I start up bluestacks I have to edit the code to change all instance of the port to the new one. Is it possible to have the script detect what port that Bluestacks is running? If not how about a way to specify the port at the command line when running the script?

ZloyPupsic commented 1 year ago

I use Bluestacks X. The ADB port defaults to 5555 after restart of the program.

TiemN commented 1 year ago

That's odd, cause I tried both 5 and X and it looks like this for me, and it changes on reboot of Bluestacks.

adb

AdriaGual commented 1 year ago

Have you tried this?

image

Here's the link to the thread but basically seems like you can force a port to bluestacks. https://www.reddit.com/r/BlueStacks/comments/qzlhg9/disabling_randomized_adb_port_on_bluestacks_5/

Hope it helps!

TiemN commented 1 year ago

I saw that thread, that file actually doesn't allow you to force the port it only tells you what the current port is.

W33dox commented 1 year ago

I have the same problem... Editing the file doesnt help... still randomized

Karo8870 commented 1 year ago

Hello! Has anyone found a solution?

ETOgaosion commented 10 months ago

Hey guys, you can see my gist to detect adb port and set proxy: https://gist.github.com/ETOgaosion/e9c2752124b1795dbe2aa9430c2a7a40

@echo off
setlocal enabledelayedexpansion
@REM read bluestack adb port
set "filepath=[PATHTO]\BlueStacks_nxt\bluestacks.conf"
set "search=bst.instance.Pie64.status.adb_port="
for /f "tokens=2 delims==" %%A in ('findstr /c:"%search%" "%filepath%"') do (
    set "result=%%A"
)
@REM read ipv4 address
ipconfig > temp.txt
set "adapterName=Wireless LAN adapter WLAN 2"
set "foundAdapter="
for /f "tokens=*" %%A in (temp.txt) do (
    set "line=%%A"
    if "!line:~0,27!"=="%adapterName%" (
        set "foundAdapter=1"
    )
    if defined foundAdapter (
        echo !line! | findstr "IPv4"
        if !errorlevel!==0 (
            set "ipv4Line=!line!"
            set "foundAdapter="
            goto :break
        )
    )
)
:break
for /f "tokens=14" %%B in ("!ipv4Line!") do (
    set "ipv4=%%B"
)
del temp.txt
adb.exe connect 127.0.0.1:%result%
adb.exe devices -l
adb.exe shell settings put global http_proxy %ipv4%:7890
adb.exe shell settings put global https_proxy %ipv4%:7890
endlocal