Page 1 of 2

shortcut for function keys (F8;F9)[SOLVED]

Posted: Tue Apr 22, 2014 2:20 pm
by atout66
Hi to all,

Is there a way to make a shortcut for a button without the prior Ctrl or Alt or Shift keys ?
I can have Ctrl+F9, Shift+F9, etc., but I didn't find yet how to have only F9, or F8 keys.

Any idea ?

Kind regards, Jean-Paul.

Re: shortcut for function keys (F8;F9)

Posted: Tue Apr 22, 2014 3:42 pm
by dunbarx
Hi.

Check out "rawKeyDown" in the dictionary.

This is a message, and you can use 65474 and 65475 as tools to do whatever you need to.

Craig

Re: shortcut for function keys (F8;F9)

Posted: Tue Apr 22, 2014 3:45 pm
by Klaus
And also check the entry for the "functionkey" message :D

Re: shortcut for function keys (F8;F9)

Posted: Tue Apr 22, 2014 3:48 pm
by dunbarx
Hmmm.

Did I misunderstand your question? Does this do what you want? In the card script:

Code: Select all

on functionKey var
   if var = 5 then answer random(999)
end functionKey
in a button script:

Code: Select all

on mouseUp
   send "functionKey" && "5" to this card
end mouseUp
Sort of the same idea. Do you see why?

Craig

Re: shortcut for function keys (F8;F9)

Posted: Tue Apr 22, 2014 4:09 pm
by Klaus
Sounds more like this (in the card script):

Code: Select all

on functionkey tKEy
  if tKey = 3 then
    send "mouseup" to btn "that namely button that shall accept a function key as shortcut, YO!"
  end if
end functionkey
:D

Re: shortcut for function keys (F8;F9)

Posted: Tue Apr 22, 2014 4:24 pm
by atout66
Yes Craig, I see why, and the "functionkey" is exactly what I was looking for.
So I've put this code in the stack and it works fine :wink:

Code: Select all

on functionKey theKey
  if theKey is 9 then send mouseUp to button "BttF9"
  else pass functionKey
end functionKey
I suppose that if the handler is in the stack I can remove the "pass functionKey", right ?
Thanks to all of you :wink:

Kind regards, Jean-Paul.

Re: shortcut for function keys (F8;F9)[SOLVED]

Posted: Tue Apr 22, 2014 4:37 pm
by atout66
It's strange because the script works with the <if> statement but not with the <switch> one ?

Code: Select all

on functionKey theKey
     switch theKey
           case theKey is 11
               send mouseUp to button "BttF11"
               break
          case theKey is 12
               send mouseUp to button "BttF12"
               break
          default
               pass functionKey
     end switch     
end functionKey
This code produce nothing :shock:
Why not :?:

Re: shortcut for function keys (F8;F9)

Posted: Tue Apr 22, 2014 6:46 pm
by atout66
After some tries here is what I did finally in the code of the stack:

Code: Select all

on functionKey theKey
     if theKey is 12 then 
          send mouseUp to button "BttF12"
     else if theKey is 11 then 
          send mouseUp to button "BttF11"
     --else pass functionKey
end if
It works but the <pass> command makes an error while compiling, so that's why I leave as a comment...

Thanks and kind regards, Jean-Paul.

Re: shortcut for function keys (F8;F9)

Posted: Tue Apr 22, 2014 6:53 pm
by Klaus
Try this:

Code: Select all

on functionKey theKey
     switch theKey
           case 11
               send "mouseUp" to button "BttF11"
               break
          case 12
               send "mouseUp" to button "BttF12"
               break
          default
               pass functionKey
               break
     end switch     
end functionKey
8)

Re: shortcut for function keys (F8;F9)

Posted: Tue Apr 22, 2014 7:30 pm
by dunbarx
Hi.

What Klaus said.

Your construction is not syntactically correct, though it seems to read logically. When you set up a "switch", you have to think of each "case" as the VALUE you want to test, not a CONDITIONAL. Do you see that? It actually makes for a simpler control structure.

Read Klaus' example, and this should fall into place right away. Now you can try thinking about the following:

case thekey is 11

This will not throw an error, though, as you discovered, it did not work. Why? What does the phrase "thekey is 11" resolve to, that the case line had to deal with? 10 points if you write back with the answer today.

Craig

Re: shortcut for function keys (F8;F9)

Posted: Tue Apr 22, 2014 7:56 pm
by atout66
Arrrghh ! I got it now :!:

Thanks to you, I didn't understand that the <case> statement expected a pure value :idea:
I was used to code otherwise, that's why :wink:

Kind regards, Jean-Paul.

Re: shortcut for function keys (F8;F9)[SOLVED]

Posted: Tue Apr 22, 2014 8:07 pm
by Klaus
This:

Code: Select all

on functionKey theKey
     switch
           case theKey = 11
               send "mouseUp" to button "BttF11"
               break
          case theKey = 12
               send "mouseUp" to button "BttF12"
               break
          default
               pass functionKey
     end switch     
end functionKey
will also work, spot the difference! :D

Re: shortcut for function keys (F8;F9)[SOLVED]

Posted: Tue Apr 22, 2014 9:12 pm
by atout66
Klaus, it's strange because to me it didn't work previously.
Now, I stop working but I'll test your code tomorrow.
Good night :wink:

Kind regards, Jean-Paul.

Re: shortcut for function keys (F8;F9)[SOLVED]

Posted: Wed Apr 23, 2014 6:09 am
by Klaus
Bonjour Jean-Paul.,
atout66 wrote:Klaus, it's strange because to me it didn't work previously.
my latest script of DIFFERENT ("spot the DIFFERENCE") than your first script! :D


Best

Klaus

Re: shortcut for function keys (F8;F9)[SOLVED]

Posted: Wed Apr 23, 2014 9:55 am
by atout66
@Klaus:
Ah, I see... you use "=" when I used "is", ie:
case theKey = 11(good) instead of
case theKey is 11(wrong), right ?

Thank you for your teachings :wink:

Kind regards, Jean-Paul.