raw-input

Python raw_input messing up string concatenation

二次信任 提交于 2019-12-02 01:50:56
问题 I am trying to do something relatively simple in Python and am surprised at how badly this isn't working for how simple it should be. I'm here just trying to concatenate three simple strings. The input typed at raw_input is "abc" in all cases below: proj = raw_input("Name of project: ") print proj ProjRegex = 'test1' + proj + 'test2' print ProjRegex Yields: abc test2abc Case 2 proj = raw_input("Name of project: ") print proj ProjRegex = 'test1%stest2' % (proj) print ProjRegex Yields: abc

How to accurately measure mouse movement in inches or centimetres for a mouse with a known DPI

◇◆丶佛笑我妖孽 提交于 2019-12-02 01:29:07
I have a Logitech G500 gaming mouse that is running at its full DPI of 5700. I'm trying to write a program in C++ that accurately measures horizontal movement of the mouse in physical units, ie. centimetres or inches. I'm using the windows API and windows raw input via the WM_INPUT message to get raw movement changes from the mouse. I'm then assuming 1 unit of movement reported through WM_INPUT is 1/5700th of an inch, and as I'm tracking the net movement of the mouse, I thought I could perform a simple calculation to yield the net physical movement: distance(inches) = total_movement_from

Python raw_input messing up string concatenation

陌路散爱 提交于 2019-12-02 01:20:31
I am trying to do something relatively simple in Python and am surprised at how badly this isn't working for how simple it should be. I'm here just trying to concatenate three simple strings. The input typed at raw_input is "abc" in all cases below: proj = raw_input("Name of project: ") print proj ProjRegex = 'test1' + proj + 'test2' print ProjRegex Yields: abc test2abc Case 2 proj = raw_input("Name of project: ") print proj ProjRegex = 'test1%stest2' % (proj) print ProjRegex Yields: abc test2abc Note that in both cases instead of printing "test1abctest2" , as expected, it's substituting test2

Is it possible to use Windows Raw Input API without a window (ie from a console application)?

淺唱寂寞╮ 提交于 2019-12-01 22:23:33
问题 Is it possible to use Windows Raw Input API without a window (ie from a console application)? I've tried using RegisterRawInputDevices but my message loops doesn't seem to get any events from GetMessage and hence just 'hangs' there. 回答1: Do you mean RegisterRawInputDevices? Since the RAWINPUTDEVICE structure requires you to specify an HWND to receive the WM_INPUT messages, no it's not possible to do this without a window. Console applications can create windows, and the window probably can

How do I get realtime keyboard input in Python?

雨燕双飞 提交于 2019-12-01 21:40:43
Is this possible? Every answer I have looked at isn't what I want. What I do though is something like in omega-rpg (which is an awesome little text-based debian rpg), but in Python instead of C. I have poked around and found some things, but nothing that's relevant to what I'm doing. Is it just easier to use raw_input() / input , or would it be more efficient to use some kind of API for doing so? TO CLEAR UP: I need a system of realtime keyboard input in Python, but I don't know whether it's easier to use an API or just raw_input() / input() . If it IS better to use an API, which is the best

Detect if keyboard or mouse events are triggered by a software

女生的网名这么多〃 提交于 2019-12-01 10:46:21
Is there a way to determine whether the keyboard or mouse events are triggered from a hardware rather than an application like TeamViewer, Steam or some other remote desktop software in a desktop application running on Windows? My purpose is not to prevent bots, but to prevent remote access to the application. It seems that RawInput API lets me detect fake events sent using SendInput API. Is it correct? The low-level keyboard/mouse hooks provided by SetWindowsHookEx() report if input was generated by actual devices or injected by application code. For a low-level keyboard hook , the hook

Detect if keyboard or mouse events are triggered by a software

ⅰ亾dé卋堺 提交于 2019-12-01 08:25:46
问题 Is there a way to determine whether the keyboard or mouse events are triggered from a hardware rather than an application like TeamViewer, Steam or some other remote desktop software in a desktop application running on Windows? My purpose is not to prevent bots, but to prevent remote access to the application. It seems that RawInput API lets me detect fake events sent using SendInput API. Is it correct? 回答1: The low-level keyboard/mouse hooks provided by SetWindowsHookEx() report if input was

How could I save data after closing my program?

瘦欲@ 提交于 2019-12-01 01:08:32
I am currently working on a phone book directory using dictionaries. I didn't know any way to save the information after closing the program. I need to save the variable Information so that I can add more later and print it. Information={"Police":911} def NewEntry(): Name=raw_input("What is the targets name?") Number=raw_input("What is the target's number?") Number=int(Number) Information[Name]=Number NewEntry() print Information Edit: I am now using the Pickle module and this is my current code, but it isnt working: import pickle Information={"Police":911} pickle.dump(Information,open("save.p

Distinguish between left and right shift keys using RAWINPUT

大憨熊 提交于 2019-12-01 00:51:03
RAWINPUT provides two flags ( RI_KEY_E0 and RI_KEY_E1 ) to check whether the left or right version of a key is pressed. This works great for CTRL, but not for left and right shift. In fact, the flags are the same for both, and the VKey is also the same ( VK_SHIFT ). How can I find out which shift was pressed? I'm working on Windows 7. Interestingly, the flags/vkey values are exactly the same no matter which shift key I'm pressing. Windows 7, and I only get VK_SHIFT, never the L/R variants Which is part of the explanation why this doesn't work the way you think it should do. There's ancient

Python raw_input ignore newline

為{幸葍}努か 提交于 2019-11-30 19:10:55
Is there a way to ignore newline characters in data entered through raw_input? I am trying to use raw_input to input a list of strings that are copied and pasted from a spreadsheet. the problem is that it appears that the new line characters cause the data to be entered prematurely. All the empty spaces will be stripped anyway, so removing the newlines as the data is entered would be an added benefit. This data needs to be entered directly through the terminal prompt and not read from a file. This is what I have done so far: names = raw_input('Shoot me some names partner: ') print 'What do you