I have a program that detects when a certain key is pressed, and it will press another key. I'm not the greatest at python, but I've tried everything I could to get this to work. My game will end after the hello world statement I've added as a test. Could somebody please tell me a way to fix this? (Note: I want the code to always stay running, waiting for user input)
https://i.stack.imgur.com/QeJ3r.png
Related
I have written a program which clocks how fast I write some text to improve my touch typing speed.
The thing is that I don't like that I have to press Enter to start the program and THEN start writing. I would like to start the program and let the timer set off exactly when I have pressed the first key.
I was thinking if it would be possible to use the first character of the text I should write instead of Enter to finish an input. If so, I could solve the problem.
I was wondering if anyone has some kind of advice on how I could do this or just solve the problem.
A quick search turned up the pynput module for me, it looks like something that you could easily build into what you are talking about.
I've been making a small game for a homework assignment using Pygame with Livewires. I've been trying to debug it, but to no success; I can't get a look at the variables I want to look at before the main loop is executed. Though I can press F10 to skip over the main loop, that just stops the Autos and Watches window from working; apparently they can only records vars when the game is paused by the debugger.
Is there a way for me to use the debugger to look at the vars in runtime? Because no matter what I do while the debugger is paused, I can't look at the data inside the game objects I want to take a look in
Thanks to Jack Zhai's suggestion, I figured it out.
When the breakpoint is hit, unpause the debugger (shortcut: F5)
Play to the point in the game you want to debug.
Repause the debugger using Break All (shortcut: Ctrl-Alt-Break)
Press F10 a few times; this makes it go a few more steps in the main livewires loop.
In the autos window, there is an entry that contains the a list of the game's objects. Look through it, until you find the one(s) you're looking for. In my case, the list of the objects was self._objects. The object I was looking for was the second, which in other words, was self._objects[1].
The dropdown arrows of the object(s) you're looking for show the object's members. If you want to look at the object's properties in a less cumbersome way, use the Interactive Debugger to assign that object to a variable. That way, you can look at its values through typing objectNameHere.objectValueHere into the interactive debug console.
In my case, I had to type in player = self._objects[1] to get it assigned, then could see the player's x position by then entering player.x into the debug console.
--
I know this answer might only work for my specific problem, so if anyone else has a better one, please post it for others' sake.
So, I'm currently planning a program using the Easygui module,
The problem I am facing is, when I press the cancel button on the GUI, it just continues, so to get past this, I want to add something to my program like:
if Easygui_Variable is None:
quit()
However, the problem I face is, I am going to have multiple easygui boxes which allow the user to press cancel, and I don't want to be using
if Easygui_Variable is None:
quit()
every time, so is there anyway I can do the above for multiple variables at a time, to make sure my program is most efficient.
I was wondering if there's a way to detect onkeyboardevents, but just to count them. I don't want to know exactly what the user has typed, but more like if he typed anything.
To be more specific:
If user presses key "a" on keyboard, I am interested to know that he pressed it (and at what time), not what the letter is.
Scenario:
User types in "hello stackoverflow" in the span of 2.5 seconds.
I want to know that he was typing something, don't care about what he typed.
Why do I want to do this? Some programs detect "keyloggers" as viruses (and they should) and I don't want my users to think it's something fishy.
Cheers.
in python keylogger itself, just keep a count in the place of recording the key stroke,
while(event.Ascii):
c++
refer: https://github.com/VigneshPrasadV
So, I am writing a game in python and pygame. I was wondering, How come I have to press the "w" key multiple times to move up? I want to be able to hold any key and that action would be repeated. Also, Why does my dagger not "swing" when the character is faced down? This site is making me mad, as I am unable to format my code correctly, so just download it please.
This is where to get all the files (including the .py file):
https://www.mediafire.com/folder/k9ai685abradg/DeadWorld_Infestation_2_18-10-39
I know how buggy it is, but I want to work on it over the summer and get some stuff done.
pygame.event.get() only notifies you if a state has changed, e.g. the state of your W-key changed to pressed. I assume that you're looking for pygame.event.get()[K_w] which tells you if a key is in a pressed-state. The details about that command can be found in the pygame docs.