raw-input

Python: How to quit CLI when stuck in blocking raw_input?

拈花ヽ惹草 提交于 2019-12-06 11:20:17
I have a GUI program which should also be controllable via CLI (for monitoring). The CLI is implemented in a while loop using raw_input. If I quit the program via a GUI close button, it hangs in raw_input and does not quit until it gets an input. How can I immediately abort raw_input without entering an input? I run it on WinXP but I want it to be platform independent, it should also work within Eclipse since it is a developer tool. Python version is 2.6. I searched stackoverflow for hours and I know there are many answers to that topic, but is there really no platform independent solution to

In Python, how could I get a user input while simultaneously running the script?

不羁的心 提交于 2019-12-06 06:14:05
In my program I am trying to take the chat from a website and printing it on my console. While that's going on I'm using raw_input to get chat from whoever is using it. My problem is that raw_input pauses the rest of the script until i say something or press enter. Is there a simple way to fix this? You have to multithread. One thread for user input and another for the background tasks. The documentation is a bit complex (I'm pretty confused by it), but it's a start: http://docs.python.org/library/threading.html You may also want to look into the curses module: http://docs.python.org/library

Trying to install module win32clipboard

▼魔方 西西 提交于 2019-12-05 19:27:26
I'm new to python and i'm trying to install win32clipboard to be able to use this code: import win32clipboard win32clipboard.OpenClipboard() win32clipboard.SetClipboardText('testing 123') win32clipboard.CloseClipboard() # get clipboard data win32clipboard.OpenClipboard() data = win32clipboard.GetClipboardData() win32clipboard.CloseClipboard() print data raw_input() How do i exactly install the necessary module to be able to do so? I'm using python version 2.72. Igonato This module is part of pywin32 module. To install: Go to http://sourceforge.net/projects/pywin32/files/pywin32/ Choose the

Is it possible to swallow a key in Raw Input?

馋奶兔 提交于 2019-12-05 10:38:43
I am using the Raw Input API because I need to be able to respond to keys from different USB HID devices differently, even if it is the same key. My window receives the WM_INPUT messages correctly. I can retrieve the RAWKEYBOARD structure to obtain all the information I need. Now I want to prevent those USB devices from being able to toggle NumLock. I am hoping that the Raw Input API might allow me to swallow the NumLock keypress? I’ve tried setting the WM_INPUT message’s Result to 1, but that doesn’t seem to have an effect. (I am writing this in C#, but since this is all low-level Windows API

Get a String from a collection of keys presses retrieved using Raw Input API

浪子不回头ぞ 提交于 2019-12-05 01:04:33
问题 I am using the Raw Input API to get a collection of key presses from a keyboard (actually, a magnetic stripe card reader that emulates a keyboard). Here are a couple of code excerpts so you can have an idea of how I'm getting the keys. [StructLayout(LayoutKind.Sequential)] internal struct RAWKEYBOARD { [MarshalAs(UnmanagedType.U2)] public ushort MakeCode; [MarshalAs(UnmanagedType.U2)] public ushort Flags; [MarshalAs(UnmanagedType.U2)] public ushort Reserved; [MarshalAs(UnmanagedType.U2)]

Registering a touch screen HID with RegisterRawInputDevices does not work

牧云@^-^@ 提交于 2019-12-04 19:36:42
I am trying to get raw input data from a Surface touch screen, using RAWINPUT API. Getting the devices list works good. But when I want to register the touch screen device with RegisterRawInputDevices, I have issues : the function returns false with 87 (ERROR_INVALID_PARAMETER) in GetLastError... I have tried different things that I read online but none work. I am using Interop on C# for very simple desktop console application, developping with Visual Studio 2013 on Windows 8.1. The target is a Surface Pro 3. The code doing the work with the API is hereunder... (sorry for the ugly editing). I

How to make non-blocking raw_input when using eventlet.monkey_patch() and why it block everything, even when executed on another thread?

て烟熏妆下的殇ゞ 提交于 2019-12-04 17:22:59
I wrote this minimum code to explain my case: import threading import time import eventlet eventlet.monkey_patch() def printing_function(): while True: # here i want to do some work print "printing" time.sleep(1) if __name__ == '__main__': thread = threading.Thread(target=printing_function) thread.start() while True: # here i want to wait for users input raw_input("raw input\n") print "inside main loop" time.sleep(1) Even i have 2 threads, both of them are blocked when i call raw_input. When i comment out eventlet.monkey_patch(), only one thread is blocked and another keep printing "printing".

How to print over raw_input's line in Python?

筅森魡賤 提交于 2019-12-04 10:00:15
Usually, when raw_input asks you to type something in and press Return, feedback is printed on a new line. How can I print over the prompt's line? Could a CR work in this case? Demo: prompt = "Question: " answer = raw_input(prompt) print answer print("Correct!") Simulated output after typing an answer and pressing Return: >> Question: my answer >> Correct! Desired output: >> Correct! Use blessings : from blessings import Terminal term = Terminal() raw_input("Question: ") print(term.move_up() + "Correct!" + term.clear_eol()) Seriously, that's it. Here's something fancier: input(term.red(

How can i use raw_input and string formatting % or %d python

两盒软妹~` 提交于 2019-12-04 06:16:19
问题 i have variable var, and it is changeable how can i use raw_input and inside raw_input make a question and use this variable i.e. z = raw_input("Is your age %d') %(var) but this don't work. Any ideas? 回答1: With raw_input , %var should also lie within the parentheses. i.e: z = raw_input("Is your age %d" % var) 回答2: I guess the cleanest way is to use format : z = raw_input("Is your age {0}?".format(var)) 回答3: Your code should be: z = raw_input("Is your age %d" %(var,) ) 来源: https:/

Can you remap keys of a specific keyboard?

僤鯓⒐⒋嵵緔 提交于 2019-12-04 04:53:21
I've got two keyboards attached to my computer. A normal full-size keyboard and a numeric keypad. I want to "remap" the keys on the numeric keypad, but leave the full keyboard alone. So, when the user presses "5" on the keypad it would get remapped to the "Media Play" key, but if the same "5" was pressed on the keypad of the full keyboard, I'd get a "5". In essence, I want to turn that seperate numeric keypad into a media control device. Unfortunately I'm not sure how to make this work. There is a "Raw Input" feature of Windows which allows to distinguish between keyboards, but that only