Ask Your Question
2

msvcrt.hbhit() and msvcrt.getch() in Wing Pro 8 on Windows 10

asked 2022-05-05 21:24:24 -0500

daoming's avatar

updated 2022-05-06 05:29:45 -0500

Hi, I am using Wing Pro 8 on Windows 10. My Python scripts use mscvrt package for hbhit() and getch(). I can get input characters without them being printed on the screen. They work fine in Windows Command window be behave differently in Wing Pro 8. Here is a test script:

import msvcrt
import time
while True:
  while msvcrt.kbhit() == 0:
    time.sleep(0.1)
  print('getting ch')
  c = msvcrt.getch()
  print(f'input: {c}')
  if c==b'e':
    exit()

When running in debug mode, msvcrt.kbhit() always returns zero and msvcrt.getch() never returns. Could it be fixed? Thank you.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2022-05-06 05:34:26 -0500

The only way for this to work is to use Configure External Console in the Debug I/O tool's Options menu and then check on the highlighted preference Use External Console. Wing will show a Windows Command window for I/O instead of using Debug I/O in the IDE window.

edit flag offensive delete link more

Comments

I love to use it in that way. Thank you.

daoming's avatar daoming  ( 2022-05-09 01:34:00 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

2 followers

Stats

Asked: 2022-05-05 21:24:24 -0500

Seen: 19 times

Last updated: May 09