У нас вы можете посмотреть бесплатно How to Enable Separate Actions for Double-Click and Drag-and-Drop on Python Files in Windows или скачать в максимальном доступном качестве, видео которое было загружено на ютуб. Для загрузки выберите вариант из формы ниже:
Если кнопки скачивания не
загрузились
НАЖМИТЕ ЗДЕСЬ или обновите страницу
Если возникают проблемы со скачиванием видео, пожалуйста напишите в поддержку по адресу внизу
страницы.
Спасибо за использование сервиса ClipSaver.ru
Learn how to configure Windows to open Python files with your editor on double-click and run the script with drag-and-drop, using a batch file and Visual Studio Code. --- This video is based on the question https://stackoverflow.com/q/79394750/ asked by the user 'elechris' ( https://stackoverflow.com/u/15307950/ ) and on the answer https://stackoverflow.com/a/79400095/ provided by the user 'elechris' ( https://stackoverflow.com/u/15307950/ ) at 'Stack Overflow' website. Thanks to these great users and Stackexchange community for their contributions. Visit these links for original content and any more details, such as alternate solutions, latest updates/developments on topic, comments, revision history etc. For example, the original title of the Question was: how to enable seperate action for double click and drag and drop for python files Also, Content (except music) licensed under CC BY-SA https://meta.stackexchange.com/help/l... The original Question post is licensed under the 'CC BY-SA 4.0' ( https://creativecommons.org/licenses/... ) license, and the original Answer post is licensed under the 'CC BY-SA 4.0' ( https://creativecommons.org/licenses/... ) license. If anything seems off to you, please feel free to drop me a comment under this video. --- Handling Double-Click vs Drag-and-Drop for Python Files on Windows When working with Python files in Windows, you might want different behaviors for double-clicking versus dragging and dropping files onto your script: Double-clicking opens the file in your editor (e.g., VS Code) Drag-and-drop passes file paths as arguments to your Python script This separation can enhance your workflow but requires custom configuration. The Challenge By default, Python files open with the Python launcher or your editor depending on file associations. Supporting drag-and-drop works when Python is the default handler, but you lose the ability to open files in your editor on double-click. You want: Default action on double-click: open in Visual Studio Code Drag-and-drop: script executes with dropped files as arguments Solution Overview Use a batch file as the default application to handle Python files. The batch file: Detects if command-line arguments exist (indicating drag-and-drop) Runs Python with these arguments Otherwise, launches VS Code for editing Step-by-Step Implementation 1. Batch Script (python_drag.cmd) Place this somewhere, e.g., C:\drag\python_drag.cmd: [[See Video to Reveal this Text or Code Snippet]] %~2: checks if a second argument exists (dragged files) START "" ... runs applications without opening extra command windows Explicitly uses full path to code.exe for clean launch 2. Register Batch File as Default Handler Update the registry to use your batch file for .py files: [[See Video to Reveal this Text or Code Snippet]] Replace paths to match your batch file location %L passes the full file path %* passes all arguments 3. (Optional) Set Drop Handler Ensure the drag-and-drop shell extension is configured: [[See Video to Reveal this Text or Code Snippet]] Most Python installations set this automatically. Notes and Tips Avoid residual console windows: Using START with executable paths avoids lingering command windows. VS Code paths changed: The code.exe binary moved out of bin folder. Use the full path as shown. Script example: You can parse sys.argv in Python to detect passed files. [[See Video to Reveal this Text or Code Snippet]] Summary By setting a custom batch file as the default open handler for Python files, you can: Run your script when files are dropped onto it Open the file in VS Code when double-clicked Keep your workflow smooth without unwanted console windows Make sure to update the registry and specify the correct paths for your system. This method keeps actions clearly separated and functional on Windows 11.