i am trying to make a program hat well count every time the space bar is pressed, but it well only count when the window is in focus.
i would love help from anyone.
^_^
help with the focus function
Re: help with the focus function
A couple things:
1) Have you examined putting a love.focus in your main.lua?
What this does is checks if your mouse is in or out of the window. (Bool is short for boolean, a true or false conditional. See more here: http://en.wikipedia.org/wiki/Boolean_data_type.)
If you need an example, the code should look something like this:
2) For future reference, it is easier if you post the code and a .love version of the file for us to know how to fix it.
If you have any questions, just feel free to ask!
1) Have you examined putting a love.focus in your main.lua?
Code: Select all
function love.focus(bool) --Run if mouse goes in or out of window
end
If you need an example, the code should look something like this:
Code: Select all
function love.load() --Run only at start of game
num = 0
end
function love.draw() --Run every time game can
love.graphics.setColor( 255, 255, 255 )
love.graphics.print( num, love.graphics:getWidth()/2, love.graphics.getHeight()/2 )
end
function love.update(dt) --Run every time the game can
end
function love.focus(bool) --Run if mouse goes in or out of window
end
function love.keypressed( key, unicode ) --Run if key is pressed
if key == ' ' then
num = num + 1
end
end
function love.keyreleased( key, unicode ) --Run if key is released
end
function love.mousepressed( x, y, button ) --Run if mouse is pressed
end
function love.mousereleased( x, y, button ) --Run if mouse is released
end
function love.quit() --Run right before game is closed
end
If you have any questions, just feel free to ask!
- Attachments
-
- counter.love
- Not very optimized, just a little example...
- (902 Bytes) Downloaded 104 times
GitHub | MLib - Math and shape intersections library | Walt - Animation library | Brady - Camera library with parallax scrolling | Vim-love-docs - Help files and syntax coloring for Vim
Re: help with the focus function
yes i have that function, and when it runs then it will only count the space bar only when the program in focus.
i want the program to run i the back gound. When the program is done it should count the number of times one hits a key (or if i can a word)
and then print the amout of times its pushed.
^_^
i want the program to run i the back gound. When the program is done it should count the number of times one hits a key (or if i can a word)
and then print the amout of times its pushed.
^_^
^_^
- slime
- Solid Snayke
- Posts: 3162
- Joined: Mon Aug 23, 2010 6:45 am
- Location: Nova Scotia, Canada
- Contact:
Re: help with the focus function
LÖVE will only process keyboard input when the window has the system's keyboard focus. It can't be used as a key logger.
Re: help with the focus function
is there any way to use lua/love engine as a
?slime wrote:key logger.
^_^
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: help with the focus function
No. Why would you want to?thejaboy wrote:is there any way to use lua/love engine as a?slime wrote:key logger.
Help us help you: attach a .love.
Re: help with the focus function
OH! Sorry, I misunderstood your question.thejaboy wrote:yes i have that function, and when it runs then it will only count the space bar only when the program in focus.
i want the program to run i the back gound. When the program is done it should count the number of times one hits a key (or if i can a word)
and then print the amout of times its pushed.
^_^
Nope, not to my knowledge. You could look into a library/modification of some sort.
GitHub | MLib - Math and shape intersections library | Walt - Animation library | Brady - Camera library with parallax scrolling | Vim-love-docs - Help files and syntax coloring for Vim
Re: help with the focus function
Ok, I have spent the last two hours looking for a modified love engine or a way to disable the focus function and i cant find anythimg.
I also think there has been a misunderstanding, i am not trying to make a key logger. the program when/if i finesh it will count
words or spaces for my brother who is a translater, and this program hopfuly will help him more accurately charch the people he works for.
so fare this is all i have done {
function love.load()
love.graphics.setBackgroundColor( 255, 255, 255 )
B = 0
end
function love.draw()
love.graphics.setColor( 0, 0, 0 )
love.graphics.print( "you have pushed the spacebar " .. B, 5, 5, 0, 1, 1 )
end
function love.update(dt)
end
function love.focus(bool)
end
function love.keypressed( key, unicode )
if love.keyboard.isDown(" ") then
B = B + 1
end
end
function love.keyreleased( key, unicode )
end
function love.mousepressed( x, y, button )
end
function love.mousereleased( x, y, button )
end
function love.quit()
end}
my problum is the focus function i would like to disable or trick or stop or somthing so the program will still count the space bar even if
the program is not in focus. any help would be... well helpful.
^_^
I also think there has been a misunderstanding, i am not trying to make a key logger. the program when/if i finesh it will count
words or spaces for my brother who is a translater, and this program hopfuly will help him more accurately charch the people he works for.
so fare this is all i have done {
function love.load()
love.graphics.setBackgroundColor( 255, 255, 255 )
B = 0
end
function love.draw()
love.graphics.setColor( 0, 0, 0 )
love.graphics.print( "you have pushed the spacebar " .. B, 5, 5, 0, 1, 1 )
end
function love.update(dt)
end
function love.focus(bool)
end
function love.keypressed( key, unicode )
if love.keyboard.isDown(" ") then
B = B + 1
end
end
function love.keyreleased( key, unicode )
end
function love.mousepressed( x, y, button )
end
function love.mousereleased( x, y, button )
end
function love.quit()
end}
my problum is the focus function i would like to disable or trick or stop or somthing so the program will still count the space bar even if
the program is not in focus. any help would be... well helpful.
^_^
^_^
Re: help with the focus function
Why not just download an existing program that does just this?
Something like WhatPulse might do everything you want.
(Of course, if you want to program such a tool yourself, that's cool, just making sure you know you're making something that already exists.)
Something like WhatPulse might do everything you want.
(Of course, if you want to program such a tool yourself, that's cool, just making sure you know you're making something that already exists.)
Who is online
Users browsing this forum: Ahrefs [Bot] and 2 guests