keyboard.play function not working correctly
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}
When calling the function with list of events it does nothing.
I've tried to save it to file or somehow share the variable but nothing has worked so far.
This is record.py
which records pressed keys and saves them to file
import keyboard
import pickle
with open('keys.txt','wb') as f:
pickle.dump(keyboard.record(until='*'),f)
And here is script.py
which loads pressed keys from file and presses them again
import keyboard
import pickle
with open('keys.txt','rb') as f:
keyboard.play(pickle.load(f))
It doesn't show up any errors, but it does nothing - it should type what was saved in the file but it doesn't.
python python-3.x pickle keyboard-events
|
show 3 more comments
When calling the function with list of events it does nothing.
I've tried to save it to file or somehow share the variable but nothing has worked so far.
This is record.py
which records pressed keys and saves them to file
import keyboard
import pickle
with open('keys.txt','wb') as f:
pickle.dump(keyboard.record(until='*'),f)
And here is script.py
which loads pressed keys from file and presses them again
import keyboard
import pickle
with open('keys.txt','rb') as f:
keyboard.play(pickle.load(f))
It doesn't show up any errors, but it does nothing - it should type what was saved in the file but it doesn't.
python python-3.x pickle keyboard-events
Do you understand whatopen('file.txt', 'wb')
's'wb'
stands for? This makes it a binary file. You can't simply write bytes to a file and expect text from it. Notepickle
just makes an object into a binary stream (bytes object) and can return an object from that stream again.
– GeeTransit
Jan 3 at 20:31
I needed to save list of events into file and this is the only way I found of doing it
– MartinqooN
Jan 3 at 20:33
The pickle.load(f) does its job, it loads correct list, but the function somehow does nothing.
– MartinqooN
Jan 3 at 20:33
Which function 'does nothing'?
– GeeTransit
Jan 3 at 20:35
keyboard.play() doesn't press or do anything, it types nothing. If I change the code to just write out the list made by pickle.load(f), it writes the correct list - list full of keyboard events, so there's no mistake in that
– MartinqooN
Jan 3 at 20:37
|
show 3 more comments
When calling the function with list of events it does nothing.
I've tried to save it to file or somehow share the variable but nothing has worked so far.
This is record.py
which records pressed keys and saves them to file
import keyboard
import pickle
with open('keys.txt','wb') as f:
pickle.dump(keyboard.record(until='*'),f)
And here is script.py
which loads pressed keys from file and presses them again
import keyboard
import pickle
with open('keys.txt','rb') as f:
keyboard.play(pickle.load(f))
It doesn't show up any errors, but it does nothing - it should type what was saved in the file but it doesn't.
python python-3.x pickle keyboard-events
When calling the function with list of events it does nothing.
I've tried to save it to file or somehow share the variable but nothing has worked so far.
This is record.py
which records pressed keys and saves them to file
import keyboard
import pickle
with open('keys.txt','wb') as f:
pickle.dump(keyboard.record(until='*'),f)
And here is script.py
which loads pressed keys from file and presses them again
import keyboard
import pickle
with open('keys.txt','rb') as f:
keyboard.play(pickle.load(f))
It doesn't show up any errors, but it does nothing - it should type what was saved in the file but it doesn't.
python python-3.x pickle keyboard-events
python python-3.x pickle keyboard-events
edited Jan 3 at 21:37
MartinqooN
asked Jan 3 at 20:26
MartinqooNMartinqooN
12
12
Do you understand whatopen('file.txt', 'wb')
's'wb'
stands for? This makes it a binary file. You can't simply write bytes to a file and expect text from it. Notepickle
just makes an object into a binary stream (bytes object) and can return an object from that stream again.
– GeeTransit
Jan 3 at 20:31
I needed to save list of events into file and this is the only way I found of doing it
– MartinqooN
Jan 3 at 20:33
The pickle.load(f) does its job, it loads correct list, but the function somehow does nothing.
– MartinqooN
Jan 3 at 20:33
Which function 'does nothing'?
– GeeTransit
Jan 3 at 20:35
keyboard.play() doesn't press or do anything, it types nothing. If I change the code to just write out the list made by pickle.load(f), it writes the correct list - list full of keyboard events, so there's no mistake in that
– MartinqooN
Jan 3 at 20:37
|
show 3 more comments
Do you understand whatopen('file.txt', 'wb')
's'wb'
stands for? This makes it a binary file. You can't simply write bytes to a file and expect text from it. Notepickle
just makes an object into a binary stream (bytes object) and can return an object from that stream again.
– GeeTransit
Jan 3 at 20:31
I needed to save list of events into file and this is the only way I found of doing it
– MartinqooN
Jan 3 at 20:33
The pickle.load(f) does its job, it loads correct list, but the function somehow does nothing.
– MartinqooN
Jan 3 at 20:33
Which function 'does nothing'?
– GeeTransit
Jan 3 at 20:35
keyboard.play() doesn't press or do anything, it types nothing. If I change the code to just write out the list made by pickle.load(f), it writes the correct list - list full of keyboard events, so there's no mistake in that
– MartinqooN
Jan 3 at 20:37
Do you understand what
open('file.txt', 'wb')
's 'wb'
stands for? This makes it a binary file. You can't simply write bytes to a file and expect text from it. Note pickle
just makes an object into a binary stream (bytes object) and can return an object from that stream again.– GeeTransit
Jan 3 at 20:31
Do you understand what
open('file.txt', 'wb')
's 'wb'
stands for? This makes it a binary file. You can't simply write bytes to a file and expect text from it. Note pickle
just makes an object into a binary stream (bytes object) and can return an object from that stream again.– GeeTransit
Jan 3 at 20:31
I needed to save list of events into file and this is the only way I found of doing it
– MartinqooN
Jan 3 at 20:33
I needed to save list of events into file and this is the only way I found of doing it
– MartinqooN
Jan 3 at 20:33
The pickle.load(f) does its job, it loads correct list, but the function somehow does nothing.
– MartinqooN
Jan 3 at 20:33
The pickle.load(f) does its job, it loads correct list, but the function somehow does nothing.
– MartinqooN
Jan 3 at 20:33
Which function 'does nothing'?
– GeeTransit
Jan 3 at 20:35
Which function 'does nothing'?
– GeeTransit
Jan 3 at 20:35
keyboard.play() doesn't press or do anything, it types nothing. If I change the code to just write out the list made by pickle.load(f), it writes the correct list - list full of keyboard events, so there's no mistake in that
– MartinqooN
Jan 3 at 20:37
keyboard.play() doesn't press or do anything, it types nothing. If I change the code to just write out the list made by pickle.load(f), it writes the correct list - list full of keyboard events, so there's no mistake in that
– MartinqooN
Jan 3 at 20:37
|
show 3 more comments
2 Answers
2
active
oldest
votes
Try to set the events from keyboard into a list first.
record.py
import keyboard as k
import pickle as p
events = k.record(until = '*')
with open('events.txt', mode = 'wb') as file:
p.dump(events, file)
script.py
import keyboard as k
import pickle as p
with open('events.txt', mode = 'rb') as file:
events = p.load(file)
# end with
k.replay(events)
It still doesn't type or do anything unfortunately
– MartinqooN
Jan 3 at 21:10
Hmm... Are you running this with IDLE?
– GeeTransit
Jan 3 at 21:10
Tried within IDLE and then within other app (google search typing) and it didn't type anything. Does it work for you?
– MartinqooN
Jan 3 at 21:12
It does... Did keyboard install properly?
– GeeTransit
Jan 3 at 21:12
Tried uninstalling keyboard module and reinstalling and still doesn't do anything
– MartinqooN
Jan 3 at 21:16
|
show 4 more comments
I solved the problem by putting "useless" functions, that don't really achieve anything. The record.py stays the same, I changed the script.py just like this:
import keyboard
import pickle
keyboard.start_recording()
keyboard.stop_recording()
with open('keys.txt','rb') as f:
keyboard.play(pickle.load(f))
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54029314%2fkeyboard-play-function-not-working-correctly%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Try to set the events from keyboard into a list first.
record.py
import keyboard as k
import pickle as p
events = k.record(until = '*')
with open('events.txt', mode = 'wb') as file:
p.dump(events, file)
script.py
import keyboard as k
import pickle as p
with open('events.txt', mode = 'rb') as file:
events = p.load(file)
# end with
k.replay(events)
It still doesn't type or do anything unfortunately
– MartinqooN
Jan 3 at 21:10
Hmm... Are you running this with IDLE?
– GeeTransit
Jan 3 at 21:10
Tried within IDLE and then within other app (google search typing) and it didn't type anything. Does it work for you?
– MartinqooN
Jan 3 at 21:12
It does... Did keyboard install properly?
– GeeTransit
Jan 3 at 21:12
Tried uninstalling keyboard module and reinstalling and still doesn't do anything
– MartinqooN
Jan 3 at 21:16
|
show 4 more comments
Try to set the events from keyboard into a list first.
record.py
import keyboard as k
import pickle as p
events = k.record(until = '*')
with open('events.txt', mode = 'wb') as file:
p.dump(events, file)
script.py
import keyboard as k
import pickle as p
with open('events.txt', mode = 'rb') as file:
events = p.load(file)
# end with
k.replay(events)
It still doesn't type or do anything unfortunately
– MartinqooN
Jan 3 at 21:10
Hmm... Are you running this with IDLE?
– GeeTransit
Jan 3 at 21:10
Tried within IDLE and then within other app (google search typing) and it didn't type anything. Does it work for you?
– MartinqooN
Jan 3 at 21:12
It does... Did keyboard install properly?
– GeeTransit
Jan 3 at 21:12
Tried uninstalling keyboard module and reinstalling and still doesn't do anything
– MartinqooN
Jan 3 at 21:16
|
show 4 more comments
Try to set the events from keyboard into a list first.
record.py
import keyboard as k
import pickle as p
events = k.record(until = '*')
with open('events.txt', mode = 'wb') as file:
p.dump(events, file)
script.py
import keyboard as k
import pickle as p
with open('events.txt', mode = 'rb') as file:
events = p.load(file)
# end with
k.replay(events)
Try to set the events from keyboard into a list first.
record.py
import keyboard as k
import pickle as p
events = k.record(until = '*')
with open('events.txt', mode = 'wb') as file:
p.dump(events, file)
script.py
import keyboard as k
import pickle as p
with open('events.txt', mode = 'rb') as file:
events = p.load(file)
# end with
k.replay(events)
edited Jan 3 at 21:11
answered Jan 3 at 21:07
GeeTransitGeeTransit
694316
694316
It still doesn't type or do anything unfortunately
– MartinqooN
Jan 3 at 21:10
Hmm... Are you running this with IDLE?
– GeeTransit
Jan 3 at 21:10
Tried within IDLE and then within other app (google search typing) and it didn't type anything. Does it work for you?
– MartinqooN
Jan 3 at 21:12
It does... Did keyboard install properly?
– GeeTransit
Jan 3 at 21:12
Tried uninstalling keyboard module and reinstalling and still doesn't do anything
– MartinqooN
Jan 3 at 21:16
|
show 4 more comments
It still doesn't type or do anything unfortunately
– MartinqooN
Jan 3 at 21:10
Hmm... Are you running this with IDLE?
– GeeTransit
Jan 3 at 21:10
Tried within IDLE and then within other app (google search typing) and it didn't type anything. Does it work for you?
– MartinqooN
Jan 3 at 21:12
It does... Did keyboard install properly?
– GeeTransit
Jan 3 at 21:12
Tried uninstalling keyboard module and reinstalling and still doesn't do anything
– MartinqooN
Jan 3 at 21:16
It still doesn't type or do anything unfortunately
– MartinqooN
Jan 3 at 21:10
It still doesn't type or do anything unfortunately
– MartinqooN
Jan 3 at 21:10
Hmm... Are you running this with IDLE?
– GeeTransit
Jan 3 at 21:10
Hmm... Are you running this with IDLE?
– GeeTransit
Jan 3 at 21:10
Tried within IDLE and then within other app (google search typing) and it didn't type anything. Does it work for you?
– MartinqooN
Jan 3 at 21:12
Tried within IDLE and then within other app (google search typing) and it didn't type anything. Does it work for you?
– MartinqooN
Jan 3 at 21:12
It does... Did keyboard install properly?
– GeeTransit
Jan 3 at 21:12
It does... Did keyboard install properly?
– GeeTransit
Jan 3 at 21:12
Tried uninstalling keyboard module and reinstalling and still doesn't do anything
– MartinqooN
Jan 3 at 21:16
Tried uninstalling keyboard module and reinstalling and still doesn't do anything
– MartinqooN
Jan 3 at 21:16
|
show 4 more comments
I solved the problem by putting "useless" functions, that don't really achieve anything. The record.py stays the same, I changed the script.py just like this:
import keyboard
import pickle
keyboard.start_recording()
keyboard.stop_recording()
with open('keys.txt','rb') as f:
keyboard.play(pickle.load(f))
add a comment |
I solved the problem by putting "useless" functions, that don't really achieve anything. The record.py stays the same, I changed the script.py just like this:
import keyboard
import pickle
keyboard.start_recording()
keyboard.stop_recording()
with open('keys.txt','rb') as f:
keyboard.play(pickle.load(f))
add a comment |
I solved the problem by putting "useless" functions, that don't really achieve anything. The record.py stays the same, I changed the script.py just like this:
import keyboard
import pickle
keyboard.start_recording()
keyboard.stop_recording()
with open('keys.txt','rb') as f:
keyboard.play(pickle.load(f))
I solved the problem by putting "useless" functions, that don't really achieve anything. The record.py stays the same, I changed the script.py just like this:
import keyboard
import pickle
keyboard.start_recording()
keyboard.stop_recording()
with open('keys.txt','rb') as f:
keyboard.play(pickle.load(f))
answered Jan 10 at 16:16
MartinqooNMartinqooN
12
12
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54029314%2fkeyboard-play-function-not-working-correctly%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Do you understand what
open('file.txt', 'wb')
's'wb'
stands for? This makes it a binary file. You can't simply write bytes to a file and expect text from it. Notepickle
just makes an object into a binary stream (bytes object) and can return an object from that stream again.– GeeTransit
Jan 3 at 20:31
I needed to save list of events into file and this is the only way I found of doing it
– MartinqooN
Jan 3 at 20:33
The pickle.load(f) does its job, it loads correct list, but the function somehow does nothing.
– MartinqooN
Jan 3 at 20:33
Which function 'does nothing'?
– GeeTransit
Jan 3 at 20:35
keyboard.play() doesn't press or do anything, it types nothing. If I change the code to just write out the list made by pickle.load(f), it writes the correct list - list full of keyboard events, so there's no mistake in that
– MartinqooN
Jan 3 at 20:37