A powerful Python abstraction layer and CLI tool for controlling LDPlayer Android emulator instances. Manage multiple emulators programmatically with comprehensive batch operation support.
- 🐍 Python API: Complete wrapper for all ldconsole commands
- 🚀 Batch Operations: Execute commands across multiple instances simultaneously
- 🔍 Auto-Discovery: Automatically detect LDPlayer installations
- ⚙️ Configuration Management: Read and modify emulator configs programmatically
- 🎯 Flexible Targeting: Select instances by name, index, list, or lambda filter
- 💾 Smart Caching: LFU cache for configuration files with automatic staleness detection
- 📝 Type-Safe: Full type hints and comprehensive docstrings
- 🛠️ CLI Tool: Intuitive command-line interface built with Click
# With CLI support
uv add ldpx[click]
# API only
uv add ldpx# With CLI support
pip install ldpx[click]
# API only
pip install ldpx# Discover LDPlayer installation automatically
ldpx discover
# Verify configuration
ldpx console query list2from ldpx.core.objs.attr import LDAttr
from ldpx.core.objs.console import Console
# Initialize (auto-discover or load from config)
attr = LDAttr.discover()
console = Console(attr)
# Single instance operations
console.launch(name="instance1")
console.installapp(index=0, filename="app.apk")
# Batch operations - by list
console.launch([0, 1, 2])
# Batch operations - by lambda filter
console.launch(instances=lambda x: x.name.startswith('game'))
# Query instances
instances = console.list2()
for inst in instances:
print(f"{inst['name']}: {inst['id']}")# Launch single instance
ldpx console exec launch --name instance1
# Batch launch by indices
ldpx console exec launch -bs "0,1,2"
# Batch launch by lambda filter
ldpx console exec launch -bl "lambda x: x['name'].startswith('game')"
# Install app on multiple instances
ldpx console app installapp --filename app.apk -bs "0,1,2"
# Query instance information
ldpx console query list2
ldpx console query isrunning --name instance1
# Modify instance settings
ldpx console config modify --name instance1 --resolution "1920x1080" --cpu 4 --memory 4096Get information about emulator instances:
list- List all instances (simple format)list2- List all instances (detailed metadata)list3- Query single instance detailsrunninglist- List running instancesisrunning- Check if instance is runninggetprop- Get system property valueoperatelist- List operations for instanceoperateinfo- Get operation information
Control emulator lifecycle:
launch- Start an emulator instancequit- Stop an emulator instancereboot- Reboot an emulator instancequitall- Stop all running instancesadd- Create new emulator instancecopy- Clone an existing instanceremove- Delete an emulator instancerename- Rename an emulator instance
Manage Android applications:
installapp- Install APK file or app by package nameuninstallapp- Uninstall app by package namerunapp- Launch an appkillapp- Stop a running applaunchex- Launch app with extended optionsbackupapp- Backup app and its datarestoreapp- Restore app and its data
Modify emulator settings:
modify- Change instance settings (CPU, memory, resolution, device info, etc.)globalsetting- Configure global settings (FPS, audio, etc.)operaterecord- Execute recorded macro/script
Transfer files between host and emulator:
pull- Download files from emulatorpush- Upload files to emulator
Utility commands:
rock- Shake the emulator windowzoomIn- Zoom in the emulator windowzoomOut- Zoom out the emulator windowsortWnd- Sort and arrange emulator windows
Batch operations allow you to execute commands on multiple instances at once.
# Indices
ldpx console exec launch -bs "0,1,2"
# Names
ldpx console exec launch -bs "instance1,instance2,instance3"# Filter by name pattern
ldpx console exec launch -bl "lambda x: x['name'].startswith('game')"
# Filter by running status
ldpx console exec quit -bl "lambda x: x['android_started_int'] == 1"# List of indices
console.launch([0, 1, 2])
# List of names
console.launch(["instance1", "instance2"])
# Lambda filter
console.launch(instances=lambda x: x['name'].startswith('test'))
# Custom function
console.launch(console_func=lambda c: c.launch(name='specific'))from ldpx.ext.obj.leidian import LeidianFile
# Initialize
leidian_file = LeidianFile(attr)
# Get global configuration
global_config = leidian_file.getLeidiansConfig()
# Get instance configuration
instance_config = leidian_file.getLeidianConfig(0)
# Modify and save
instance_config.basicSettings['fps'] = 120
leidian_file.dumpLeidianConfig(instance_config)from ldpx.ext.obj.kmp import KMPFile
kmp_file = KMPFile(attr)
# List available mappings
mappings = kmp_file.customizeList()
# Load a mapping
mapping = kmp_file.getCustomize("game_mapping.kmp")
# Modify and save
# ... modify mapping ...
kmp_file.dump("game_mapping.kmp", mapping)from ldpx.ext.obj.record import RecordFile
record_file = RecordFile(attr)
# List recordings
recordings = record_file.recordList()
# Load a recording
record = record_file.getRecord("automation.record")
# Execute on instance
console.operaterecord(name="instance1", content=record)- Python 3.12 or higher
- Windows OS (LDPlayer is Windows-only)
- LDPlayer installed
- psutil for process discovery
- click for CLI (optional)
LDPX stores configuration in ~/.ldpx/ld/config.json:
{
"path": [
"C:/path/to/LDPlayer",
"D:/another/installation"
]
}Add paths manually or use ldpx discover for automatic detection.
Full API documentation with docstrings is available in the source code. Each module, class, and function includes comprehensive documentation.
Contributions welcome! Please ensure:
- Code follows existing patterns
- Type hints are included
- Docstrings are comprehensive
- Tests pass (when test suite is added)
MIT License - see LICENSE file for details
- LDPlayer for providing the ldconsole CLI tool
- Click framework for CLI capabilities
- psutil for process management
For issues, questions, or contributions, please visit the project repository.
Note: This tool requires LDPlayer to be installed and is Windows-only due to LDPlayer platform constraints.