Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Need to assign a shortcut key...

  • 11-01-2014 12:25am
    #1
    Registered Users, Registered Users 2 Posts: 2,359 ✭✭✭


    In a program we use, we print a lot of labels.

    I need to shorten the steps required to print off each label after is asks us how many labels we want to print as it slows down the printing process as this is a frequent task on this pc... (windows 7)

    It goes like this... we select the info required to print -> we select print in the program -> we enter the number of labels we require with that particular info we need -> (and it now previews the label as how it will look printed out - and this is the shortcut combo i now need...) -> File -> Print -> Left Key -> Return Key

    F12 is not used in the software we use so this key could be assigned.

    So, is there any way to assign F12 to do the combo of File -> Print -> Left Key -> Return Key in that order?

    Thanks for any help with this.


Comments

  • Registered Users, Registered Users 2 Posts: 772 ✭✭✭maki


    As far as I know there's nothing built into Windows that will allow key macros like that. You'd need to use a third party program like Autohotkey.


  • Registered Users, Registered Users 2 Posts: 6,242 ✭✭✭bonzodog2


    Are there accelerators on Left Key -> Return Key like there is on File -> Print ? Even with 4 levels, once you have the keys remembered, its pretty quick to type


  • Moderators, Recreation & Hobbies Moderators, Science, Health & Environment Moderators, Technology & Internet Moderators Posts: 92,381 Mod ✭✭✭✭Capt'n Midnight


    some keyboards have extra buttons for macros

    but haven't seen them in years


  • Registered Users Posts: 7 mister_minn


    AutoIT would be another free option

    If you need to stick to something native Windows then have a look at powershell (Type "ISE" into the windows "Searck" box)

    Start with http://blogs.technet.com/b/heyscriptingguy/archive/2011/01/10/provide-input-to-applications-with-powershell.aspx and also

    http://stackoverflow.com/questions/17142389/powershell-sending-keystrokes-e-g-f5-after-opening-an-application

    When you get it up and running and your script file saved, you can call it from the command line with "powershell.exe" <path to your .ps1 file>. You should be able to set up a shortcut to do this and assign a keyboard shortcut to it

    Here's a starting point. I cannot find a link so this is the code. (As it's open source and credits are included,I'm presuming it's ok to post it here) Just type "ISE" in to the windows search and then paste this in to the top window and hit the green run arrow
    ##############################################################################
    #  Script: Control_GUI_App.ps1
    #    Date: 27.Mar.2007
    # Version: 2.0
    #  Author: Jason Fossen (www.WindowsPowerShellTraining.com)
    # Purpose: Demos use of SendKeys(), Start-Sleep, and AppActivate().
    #   Legal: Script provided "AS IS" without warranties or guarantees of any
    #          kind.  USE AT YOUR OWN RISK.  Public domain, no rights reserved.
    ##############################################################################
    
    
    # Create the famous oWshShell object used in many VBScripts.
    $oWshShell = New-Object -COMobject "WScript.Shell" -Strict 2>$Null
    
    
    # Delete the exported file from last time...(housecleaning)
    Remove-Item "$env:userprofile\desktop\EventLog.evt" 2>$Null
    
    
    # Launch the MMC snap-in for Event Viewer.
    Invoke-Expression "$Env:SystemRoot\system32\eventvwr.msc /s"
    
    
    # Make the script pause for two seconds to let the snap-in show.
    # If you try to send keystrokes to an application that has not yet fully 
    # launched, the application will simply miss the keystrokes.
    Start-Sleep -seconds 2
    
    
    # Though Event Viewer should be in the foreground, this helps to ensure it.
    # AppActivate() looks for the exact titlebar name of a running application and
    # then brings that application to the foreground and gives it the focus.
    # You can use this method to switch between different applications.  You can also
    # give AppActivate() a process ID number (PID) to bring to the foreground.  
    $Result = $oWshShell.AppActivate("Event Viewer")
    
    
    # Now send keystrokes to Event Viewer.  The Start-Sleep commands are not really needed,
    # but slowing the execution down a bit makes the demo look better!
      
    $oWshShell.SendKeys("{PGUP}")     # Hit Page Up key to put focus at top of tree.
    $oWshShell.SendKeys("{DOWN}")     # Hit the down-arrow key.
    Start-Sleep -milliseconds 400
    $oWshShell.SendKeys("{DOWN}")
    Start-Sleep -milliseconds 400
    $oWshShell.SendKeys("{DOWN}")
    Start-Sleep -milliseconds 400
    $oWshShell.SendKeys("%A")         # Hit Alt-A for the Action menu.
    Start-Sleep -milliseconds 400
    $oWshShell.SendKeys("{DOWN}")
    Start-Sleep -milliseconds 400
    $oWshShell.SendKeys("{ENTER}")    # Hit Enter key.
    Start-Sleep -milliseconds 400
    $oWshShell.SendKeys("$env:userprofile\desktop\EventLog.evt")
    Start-Sleep -seconds 2
    $oWshShell.SendKeys("{TAB}")      # Tab over to Save button.
    Start-Sleep -milliseconds 400
    $oWshShell.SendKeys("{TAB}")
    Start-Sleep -milliseconds 400
    $oWshShell.SendKeys("{ENTER}")
    Start-Sleep -milliseconds 500
    $oWshShell.SendKeys("%{F4}")      # Alt-F4 closes the MMC window.
    
    
    # Now just to do something fun....  But also notice that parentheses (()), the
    # tilde character (~), the percentage sign (%), the power sign (^), and the plus
    # sign (+) must be placed inside of curly brackets into order to be sent to the
    # application because these characters are meaningful to the SendKeys() method.
    notepad.exe
    Start-Sleep -seconds 1
    
    # And, again, the following Sleep commands are just for effect.  Otherwise, the
    # picture would show up so fast as to appear to have been from a file that was opened.
    $Result = $oWshShell.AppActivate("Untitled")
    $oWshShell.SendKeys("{ENTER}")
    $oWshShell.SendKeys("        /\_/\")
    Start-Sleep -milliseconds 400
    $oWshShell.SendKeys("{ENTER}")
    $oWshShell.SendKeys("       / 0 0 \")
    Start-Sleep -milliseconds 400
    $oWshShell.SendKeys("{ENTER}")
    $oWshShell.SendKeys("      ====v====")
    Start-Sleep -milliseconds 400
    $oWshShell.SendKeys("{ENTER}")
    $oWshShell.SendKeys("       \  W  /")
    Start-Sleep -milliseconds 400
    $oWshShell.SendKeys("{ENTER}")
    $oWshShell.SendKeys("       |     |     _")
    Start-Sleep -milliseconds 400
    $oWshShell.SendKeys("{ENTER}")
    $oWshShell.SendKeys("       / ___ \    /")
    Start-Sleep -milliseconds 400
    $oWshShell.SendKeys("{ENTER}")
    $oWshShell.SendKeys("      / /   \ \  |")
    Start-Sleep -milliseconds 400
    $oWshShell.SendKeys("{ENTER}")
    $oWshShell.SendKeys("     {(}{(}{(}-----{)}{)}{)}-'") # Notice the curly brackets.
    Start-Sleep -milliseconds 400
    $oWshShell.SendKeys("{ENTER}")
    $oWshShell.SendKeys("     /         \")
    Start-Sleep -milliseconds 400
    $oWshShell.SendKeys("{ENTER}")
    $oWshShell.SendKeys("     {(}      ___{)}") # More curly brackets.
    Start-Sleep -milliseconds 400
    $oWshShell.SendKeys("{ENTER}")
    $oWshShell.SendKeys("      \__.=|___E")
    Start-Sleep -milliseconds 400
    $oWshShell.SendKeys("{ENTER}")
    $oWshShell.SendKeys("             /")
    $oWshShell.SendKeys("{ENTER}")
    Start-Sleep -seconds 2
    $oWshShell.SendKeys("%{F4}")  # To close Notepad.
    $oWshShell.SendKeys("%N")     # To say No to saving.
    
    
    # The following is the syntax for sending special keystrokes with SendKeys().
    # Shift Key      +
    # Ctrl Key       ^
    # Alt Key        %
    # Backspace      {BACKSPACE}, {BS} or {BKSP}
    # Break          {BREAK}
    # Caps Lock      {CAPSLOCK}
    # Delete         {DELETE} or {DEL}
    # Cursor Up      {UP}
    # Cursor Down    {DOWN}
    # Cursor Right   {RIGHT}
    # Cursor Left    {LEFT}
    # End            {END}
    # Enter          {ENTER} or ~
    # Esc            {ESC}
    # Home           {HOME}
    # Insert         {INSERT} or {INS}
    # Num Lock       {NUMLOCK}
    # Page Down      {PGDN}
    # Page Up        {PGUP}
    # Scroll Lock    {SCROLLOCK}
    # Tab            {TAB}
    # F1, F2, F3...  {F1}, {F2}, {F3}...
    # 
    # To close a program, use Alt-F4 = %{F4}
    # 
    # To access menu commands, look for the underlined letters on the menus, then
    # enter Alt-letter, e.g., %F to pull down the File menu, then %X to Exit.
    # 
    # Note: It's not possible to script Ctrl-Alt-Del.
    # 
    # To hold down one key and press others, the symbol for the held key should
    # be followed with parentheses in which the other keys should be listed.  For 
    # example, to send Shift-A-B, enter +(AB), or to send Alt-C-D-E, enter %(CDE).
    # 
    # To repeat a keystroke multiple times, inside curley brackets place the keystroke,
    # a space character, and the multiple number.  For example, to enter the letter R
    # tenty times, use {R 20}.
    
    
    # END OF SCRIPT ****************************************************************
    


  • Registered Users, Registered Users 2 Posts: 2,359 ✭✭✭Access


    bonzodog2 wrote: »
    Are there accelerators on Left Key -> Return Key like there is on File -> Print ? Even with 4 levels, once you have the keys remembered, its pretty quick to type

    True... but not when this has to be done approx 100 to 200 times in a working day and there are many steps previous to this point too

    I just want to shorten the steps required for the person doing it.


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 6,242 ✭✭✭bonzodog2


    Try http://ghost-mouse.com/ ; it records mouse actions and plays them back when you hit Ctrl-F2


  • Registered Users Posts: 7 mister_minn


    Access wrote: »
    True... but not when this has to be done approx 100 to 200 times in a working day and there are many steps previous to this point too

    I just want to shorten the steps required for the person doing it.

    None of these may be robust enough for frequently ran business application. They all depend on keystrokes being sent to the right place at the right time. I'm curious to what the left key in File -> Print -> Left Key -> Return Key is doing for you. If it's merely selecting a different printer then you may be better looking at something like http://www.computedsynergy.com/products-automatic-printer-switcher.html


Advertisement