FAQFAQ   SearchSearch   UsergroupsUsergroups   RegisterRegister   ProfileProfile    Log inLog in   RSS Feed

can I make an script that recognices key down and key up?

 
Post new topic   Reply to topic    Salling Software Forums Forum Index -> Scripting Salling Clicker for Mac
View previous topic :: View next topic  
Author Message
gamuso
Junior Member


Joined: 01 Feb 2007
Posts: 27

PostPosted: Mon Apr 23, 2007 1:04 am    Post subject: can I make an script that recognices key down and key up? Reply with quote

hello...

here I am again trying to make things work better.

so, I would like that my script would recognice if I let my finger pushing down the key... and so the moment in which I stop pressing the key...

Is that possible with a phone?

thakyou so.

david
Back to top
View user's profile Send private message
salling
Site Admin


Joined: 27 Jul 2004
Posts: 7498
Location: Stockholm, Sweden

PostPosted: Mon Apr 23, 2007 1:18 am    Post subject: Reply with quote

But of course. Lots of our scripts do this.

You need either a "keypad screen" or "mediaplayer screen" widget. Then handle the "process key down" and "process key up".

I suggest you have a look at the boiler-plate script code generated for you when you create a keypad script.

Best.
--
Jonas
Back to top
View user's profile Send private message Send e-mail Visit poster's website
gamuso
Junior Member


Joined: 01 Feb 2007
Posts: 27

PostPosted: Mon Apr 23, 2007 1:25 pm    Post subject: More help needed... as ussual... Reply with quote

Well... I don´t understand the most of the things you have told me. But I have this:

using terms from application "SEC Helper"


on process invoke term
tell term
set player to make new keypad screen with properties {title:"Wireless Keyboard & Mouse", sends pen events:true}
tell player
make new text row with properties {horizontal alignment:left, overflow:wrap, font size:small, textual content:¬
"Prueba para key up and down
" & return ¬
}
end tell
push player
end tell
end process invoke



on process key down keyCode sent from pad
tell application "Live"
activate
end tell
tell application "SEC Helper"

if keyCode = "1" then
simulate keyboard virtual keycode 0
show screen message "1"

end if

end tell
return (true)
end process key down

end using terms from

What and how could I do to make number "1" to keep "active" until I do stop pressing the it´s key?

Thanks a lot, I so sorry to know so few about scripting... too many things already in my head!.
Back to top
View user's profile Send private message
salling
Site Admin


Joined: 27 Jul 2004
Posts: 7498
Location: Stockholm, Sweden

PostPosted: Mon Apr 23, 2007 5:39 pm    Post subject: Reply with quote

Not sure what virtual keycode 0 is supposed to do (this looks like a mistake).

Here's what you do:

simulate keyboard virtual down keycode xxxx

and

simulate keyboard virtual up keycode xxxx

Best.
--
Jonas
Back to top
View user's profile Send private message Send e-mail Visit poster's website
gamuso
Junior Member


Joined: 01 Feb 2007
Posts: 27

PostPosted: Tue Apr 24, 2007 9:02 am    Post subject: I feel stupid... Reply with quote

hello, sorry, but the script I have sent to you is a simplification one from my real one. The real one have got "modifiers", and so I can not introduce "up" or "down" in the line, as the script tell me errors.

But when I have tryed with the simpler one tiping

"if keyCode = "1" then
simulate keyboard virtual down keycode 0
show screen message "1"

it doesn´t stop when I stopt presing key 1 (keycode 0 is = a) so it says aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa. and never stops even when I don´t press key 1.

this is my real script (not including all number keys!):


property modifieroption : false
property modifierShift : false
property modifierList : {}


using terms from application "SEC Helper"



on process invoke term
tell term
set player to make new keypad screen with properties {title:"Wireless Keyboard & Mouse", sends pen events:true}
tell player
make new text row with properties {horizontal alignment:left, overflow:wrap, font size:small, textual content:¬
"Este sirve para: Disparar Rusos
" & return & ¬
"Red Button: Right Click " & return & ¬
"Center Button: Toggle Command" & return & ¬
"Mail Button: Toggle Control" & return & ¬
"Option + Mail Button: Toggle Option " & return & ¬
"Option + Green Button: Escape " & return & ¬
"Option + Red Button: Tab " & return ¬
}
end tell
push player
end tell
end process invoke


on process key down keyCode sent from pad
tell application "Live"
activate
end tell
tell application "SEC Helper"
-- show screen message keyCode

if keyCode = "^" then
-- Mail Key -- Shift Modifier
if modifierShift then
set modifierShift to false
show screen message "AUX OFF"
else
set modifierShift to true
show screen message "AUX ON"
end if
else if keyCode = "v" then
-- option + mail -- option
if modifieroption then
set modifieroption to false
show screen message "EFECTS OFF"
else
set modifieroption to true
show screen message "EFECTS ON"
end if
else
set modifierList to {}

if modifieroption then
set modifierList to {} & {"option"}
end if

if modifierShift then
set modifierList to {} & {"shift"}
end if

if keyCode = "1" then
simulate keyboard virtual keycode 0 modifiers modifierList
show screen message "1"
end if

set modifieroption to false
set modifierShift to false
end if
end tell
return (true)
end process key down



end using terms from


your software is being so helpfull!. so is your unstopped activity... thanks a lot for it... I will understand if you can not tell me the solution... but I had to try!.

best.

david
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Salling Software Forums Forum Index -> Scripting Salling Clicker for Mac All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group