Sign in to follow this  
Followers 0
Dev

Transform With A Function

3 posts in this topic

I need some help with this function:

Func transformkey($key)
Select
    Case $key = "F1"
  Send("{F1}")
    Case $key = "F2"
  Send("{F2}")
    Case $key = "F3"
  Send("{F3}")
    Case $key = "F4"
  Send("{F4}")
    Case $key = "F5"
  Send("{F5}")
    Case $key = "F6" 
  Send("{F6}")
    Case $key = "F7"
  Send("{F7}")
    Case $key = "F8"
  Send("{F8}")
EndSelect
EndFunc

If $mykey = F3, and i call the function like this: transformkey($mykey), it doesnt work. something wrong with the code? :postal:

:iamstupid:

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

That can be re-written as simply:

Func TransformKey($key)
    Send("{" & $key & "}")
EndFunc

Are you using a hotkey and trying to pass those key-presses on to Windows after doing your own handling? If so, you have to disable the hotkey first or you'll throw AutoIt into an infinite loop... If that is the case, then something like this would work:

HotKeySet("{F1}", "OnF1Key")
HotKeySet("{F2}", "OnF2Key")
; ...

Func TransformKey($key)
    Local $k = "{" & $key & "}"; Shorthand
    HotKeySet($k)
    Send($k)
    HotKeySet($k, "On" & $key & "Key")
EndFunc

NOTE: All code untested.

Edited by Valik

Share this post


Link to post
Share on other sites

Ive got allcode exept this, the first one looks nice. thanks!

:iamstupid:

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0