C program to execute shortcut keys

Discussion in 'Mac Programming' started by qwert321321, Jul 28, 2010.

  1. qwert321321 macrumors newbie

    Joined:
    Jul 28, 2010
    #1
    I wish to create a C program, or just a script that would send keyboard combinations to the keyboard.

    I was thinking of writing to the keyboard device file, but I am not quite sure how to do this.

    Thank you, qwert
     
  2. GorillaPaws macrumors 6502a

    GorillaPaws

    Joined:
    Oct 26, 2003
    Location:
    Richmond, VA
    #2
    I think Applescript would probably be the quickest/easiest way to achieve this. Can you be more specific about what your ultimate goal is? I think that info would get you better advice. Are you trying to interact with 3rd party apps?
     
  3. qwert321321 thread starter macrumors newbie

    Joined:
    Jul 28, 2010
    #3
    Here is an example of the kind of thing I want to do:

    1 highlight text in safari with mouse
    2 copy text (cmd-c)
    3 switch to previous tab (cmd-shift- leftarrow)
    4 go to search bar (alt-tab, alt-tab, alt-tab ......)
    5 paste (cmd-v)
    6 select search button (alt-tab)
    7 open in new tab (cmd-enter)

    or say

    1 highlight text with mouse
    2 copy text (cmd-c)
    3 switch to terminal (cmd-tab or something)
    4 go to dir ("cd /Users/qwert/notes)
    5 make/open note ("vi note.txt")
    6 append ( "a" )
    7 paste text (cmd-v)
    8 save and quit vim (esc, ":qw")
    9 switch back to last application (cmd-tab)


    I know there are MANY ways of doing these things; but I was thinking shortcut keys would keep things from getting too application specific.
    Also being able to do this with C would allow for some cool string parsing, or inserting dates, etc.
     

Share This Page