This Python script automates a series of tasks related to web development using tools like Visual Studio Code, PowerShell, and commands for PHP and NPM projects.
- Opens PowerShell with a specified folder path.
- Executes commands (e.g.,
php artisan serve,npm run dev) in the opened PowerShell window. For Laravel Purposes. - Opens a new tab and splits it into multiple tabs to execute commands concurrently.
- Opens Visual Studio Code with the specified folder path.
- Python
- Visual Studio Code
- PowerShell
pyautogui,pygetwindow, andsubprocessPython modules
Make sure the necessary software is installed and accessible via the specified paths in the script.
- Ensure that the required modules are installed (
pyautogui,pygetwindow,subprocess). - Update the script with your preferred folder paths for the project, Visual Studio Code, and PowerShell.
- Run the script using Python:
python script.py. - Optionally, you can pass arguments to the script to customize folder paths:
python script.py --folder_path "your_folder_path" --vs_code_path "your_vs_code_path" --power_shell_title "your_power_shell_title"Serching for help?
python script.py --help- Locate Your Python Script:
- Ensure you know the full path to your Python script (e.g.,
C:\path\to\your\script.py).
- Ensure you know the full path to your Python script (e.g.,
- Create a Shortcut:
- Right-click on your desktop.
- Navigate to
New>Shortcut.
- Specify the Script Path:
-
In the "Type the location of the item" field, paste the full path to your Python executable (e.g.,
"C:\path\to\python.exe") followed by the full path to your Python script (e.g.,"C:\path\to\your\script.py"). and the args for the scriptTo find where is located the python interpreter path:
import os import sys os.path.dirname(sys.executable)
Example:
"C:\Users\Jonathan Pabon\AppData\Local\Programs\Python\Python311\pythonw.exe" "C:\Users\Jonathan Pabon\work" --folder_path "C:\Users\Jonathan Pabon\Documents\Dev\Tiendas\TVA"
The args can be hardwritten in the script.
-
Click
Next.
-
- Name Your Shortcut:
- Provide a name for your shortcut (e.g., "Work").
- Click
Finish.
- Optional: Customize Shortcut Icon:
- Right-click on the shortcut you created.
- Select
Properties. - In the
Shortcuttab, click onChange Icon.... - Browse and select an icon for your shortcut (you can use the provided icon file or select from system icons).
- Click
OKto confirm.
- Run Your Script:
- Double-click on the desktop shortcut to execute your Python script with predefined configurations.
By following these steps, you can create a convenient desktop shortcut for launching your Python script with ease, improving your workflow efficiency in web development tasks.