Josef Lazar
Josef Lazar

Reputation: 1

opening Python IDLE with AutoHotKey

I've been messing around with AutoHotKey, trying to create some useful shortcuts for myself. I can open file explorer, calculator, chrome, etc., but I haven't been able to write a program that opens Python IDLE.

My program says:

!t::
Run pythonw
return

I've tried pythonw.exe, python.exe, python, python3.exe, and a bunch of other combinations. Any idea why it isn't working? Thanks!

Upvotes: 0

Views: 167

Answers (3)

Terry Jan Reedy
Terry Jan Reedy

Reputation: 19174

idle.bat is Windows specific, and there are Windows-specific reasons for its existence. The generic way to start IDLE in its default startup mode (partly user customizable) is somepython -m idlelib where somepython refers to and start a python binary. It can be python, pythonw (Windows), python3 (*nix), or py -3.y (Windows). For 2.x, use idlelib.idle instead of idlelib.

Upvotes: 0

Spyre
Spyre

Reputation: 2344

Turning the info that Jaysmito provided into an AutoHotkey Script:

!t::
Run C:\Python39\Lib\idlelib\idle.bat
return

However, the Python39 part of the directory above will vary based on which version of python you have installed. To check which version of Python you are using, use the python --version command in a command prompt window. Then if your version of Python is not in the 3.9.* range, change the directory above to match your version.

For example, if your version is in the 2.7.* range, your directory would be something like Run C:\Python27\Lib\idlelib\idle.bat, with the Python39 from above changed to Python27.

Upvotes: 0

Jaysmito Mukherjee
Jaysmito Mukherjee

Reputation: 1526

So, your problem is that Python IDLE is different from pythonw.exe, python.exe, python, python3.exe .

Python IDLE is an IDE or Code Editor provided with python whereas pythonw.exe, python.exe, python, python3.exe are the python interpreter.

pythonw.exe - for executing python scripts without opening console window(Hidden) python OR python3.exe OR python3.exe - are the same, that is the normal python interpreter.

So to open IDLE you should execute the IDLE file not the interpreter.

The path for IDLE(in Windows Computer) is usually :

C:\Python39\Lib\idlelib\idle.bat

Here the Python version is 3.9 but it may be different in your case! Check for the version you installed by opening command prompt and typing :

C:\>python --version
Python 3.9.1

Upvotes: 1

Related Questions