10 Replies Latest reply on Dec 11, 2013 12:25 PM by AdamSadow

    How to Find+Replace Using a Custom Keyboard Shortcut

    AdamSadow

      Title

      How to Find+Replace Using a Custom Keyboard Shortcut

      Post

           Morning,
           1) I am trying to create a custom keyboard shortcut ("command+1") so I can find a specific field ("lastname") in the current record and replace it with specific text ("YES") in order to save time.
            
           I am using FMP 11 Pro.  I am having difficulty getting it right with the custom menu.
            
           Thank you,
           Adam

        • 1. Re: How to Find+Replace Using a Custom Keyboard Shortcut
          philmodjunk

               Command 1 is the keyboard short cut for the first script in your scripts menu so you should be able to just list this script first in the scripts menu and not need a custom menu to make this work.

               If you are having trouble with the actual script, is your script just replacing the text of Lastname in the current record with "Yes" or is it doing more than that?

          • 2. Re: How to Find+Replace Using a Custom Keyboard Shortcut
            AdamSadow

                 Phil,

                 Sorry about that. New here. Great info. you gave me; worked perfectly right away!

                 If I may ask another question: I need 7 scripts but am already using 7 (command+1-7). What would you suggest? I love the simplicity of command+1!  Is there perhaps a way to set up scripts depending on the user?

                 I'm trying to help a colleague enter student data and she is currently doing it by hand!!  Take her 2 1/2 days as of now!!

                 Thank you again for your time and help,

                 Adam

            • 3. Re: How to Find+Replace Using a Custom Keyboard Shortcut
              philmodjunk
                   

                        Is there perhaps a way to set up scripts depending on the user?

                   Scripts can call other scripts, so the script performed by command 0 - 9 can use get ( accountName ) or Get ( AccountPrivilegeSetName ) to identify the user and then use perform script to perform a different script depending on the user, but the name of the script will be the same in all cases so this may not work as well as you would like.

                   It's also possible to use the OnLayoutKeystroke trigger with If steps that use Get ( TriggerModifierKeys ) and Get ( TriggerKeystroke ) to identify what combination of key and modifiers (Shift, option, command, control) were pressed. But this is limited by the fact that both the OS and FileMaker pre-empt the vast majority of modifier key + keystroke combinations that you might use. On my windows system, for example, Ctrl-1, throught Ctrl-0 take the place of command 1 through command to peform the first 10 scripts from the scripts menu. But you might try ctrl-1 through Ctrl-0 on your Mac system to see if they work. (I can use Shift 1 through Shift 0 if I want to set this up on my windows system....)

              • 4. Re: How to Find+Replace Using a Custom Keyboard Shortcut
                AdamSadow

                     Phil,

                     I'll try Ctrl+1-7. Which of the two scripts above would you suggest?  Where would I insert the script?

                     Thanks again. 

                     Sincerely,

                     Adam

                • 5. Re: How to Find+Replace Using a Custom Keyboard Shortcut
                  philmodjunk

                       I can't quite understand your question. What two scripts are your referring to? I only see a very vague description of one script in your initial post.

                       I first suggest testing to see if ctrl-1 through ctrl-7 will actually work.

                       Write this script:

                       Show Custom Dialog [Get ( TriggerModifierKeys ) & ":" & Get ( TriggerKeystroke ) ]
                       Exit Script [false]

                       Open layout set up on one of your database layouts and select the OnLayoutKeytroke trigger to perform this script.

                       The press each of the ctrl-number keys in turn to make sure that each one pops up the custom dialog. This won't work in windows due to the key combination being "preempted" by FileMaker to perform scripts from the script menu, but since Command key-number key combinations do that in Macs, it may work on Mac systems.

                       But if it doesn't work, you'll have to do something else...

                  • 6. Re: How to Find+Replace Using a Custom Keyboard Shortcut
                    AdamSadow

                         Where would I write the script you suggest?  Would I enter it in the "Scripts" menu or somewhere else?  In it goes in the "Scripts" menu, how would I enter the script?

                    • 7. Re: How to Find+Replace Using a Custom Keyboard Shortcut
                      philmodjunk

                           There is only one place to create a script, in the scripts editor, and all scripts will be listed when you open Manage | Scripts, but there are numerous ways that you can get to the script editor from different parts of the FileMaker interface.

                           One way is to select Manage | Scripts, click new and then create the script. Once created, you can go to Layout Setup to set up the script trigger to perform this script. But users with FileMaker 11 or newer, can also get to the script editor from the Specify script dialog that you can open from the script triggers tab. The end result is the same.

                      • 8. Re: How to Find+Replace Using a Custom Keyboard Shortcut
                        AdamSadow

                             Understand.  Have created scripts before.  Using FMP 11 on Mac OS.

                             1) After naming the script, I add "Show Custom Dialog."  After clicking "Specify," where would I input the rest of the script, in "General" or "Input Scripts?"  Do I enter anything else in the "General" or "Input Fields?"  Do I substitute anything in the script: "Get ( TriggerModifierKeys )" or "Get ( TriggerKeystroke )?"

                             2) Concerning triggers, I know how to get into it through the layout mode, select "OnLayoutKeystroke,", and select the script.  How do I tell the script to trigger and replace the field I've chosen (period1, which has the default text of "NO") with "YES" and where do I input to trigger on which keys, like control+1 for period 1, control+2 for period 2, etc.?  All 7 periods currently have "NO" in the field I am looking to replace with "YES", depending on if the student record being viewed can exempt any of the periods' midterm exams.

                              

                             Thank you again very much,

                             Adam

                        • 9. Re: How to Find+Replace Using a Custom Keyboard Shortcut
                          philmodjunk

                               All you need do is copy and paste:

                               Get ( TriggerModifierKeys ) & ":" & Get ( TriggerKeystroke )

                               Directly into the Message box.

                          • 10. Re: How to Find+Replace Using a Custom Keyboard Shortcut
                            AdamSadow

                                 Phil,

                                 Got it!  perfect.  I would like to thank you again for your time, help, and patience!

                                 Sincerely,

                                 Adam