• Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Register
  • Login
TRIGGERcmd
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Register
  • Login

Press the Down Arrow key (or any other key)

Windows
17
40
15.1k
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R
    Russ
    last edited by Russ Mar 28, 2021, 7:13 PM Aug 9, 2017, 8:55 PM

    You could use this to advance your Powerpoint slides for instance, if you had something like this setup.

    Save this text to c:\scripts\key.vbs:

    Dim Wsh
    Set Wsh = Wscript.CreateObject("Wscript.Shell")
    Wsh.SendKeys "{" + WScript.Arguments.Item(0) +"}"
    

    Then create a command that runs this:

    wscript c:\scripts\key.vbs down
    

    You could also make a batch file script that types things like this:

    wscript d:\scripts\key.vbs T
    wscript d:\scripts\key.vbs R
    wscript d:\scripts\key.vbs I
    wscript d:\scripts\key.vbs G
    wscript d:\scripts\key.vbs G
    wscript d:\scripts\key.vbs E
    wscript d:\scripts\key.vbs R
    wscript d:\scripts\key.vbs c
    wscript d:\scripts\key.vbs m
    wscript d:\scripts\key.vbs d
    

    Or you could use a vbs script like this:

    Dim Wsh
    Set Wsh = Wscript.CreateObject("Wscript.Shell")
    Wsh.SendKeys "{T}{R}{I}{G}{G}{E}{R}{c}{m}{d}"
    

    This article has more info about special keys.
    Also this article is helpful:
    https://docs.microsoft.com/en-us/office/vba/language/reference/user-interface-help/sendkeys-statement

    EDIT 3/28/2021: I've since learned about nircmd's sendkeypress feature which is nice and easy to use. For example you could send ctrl s with this command:

    nircmd sendkeypress ctrl+s
    

    Russell VanderMey

    R 1 Reply Last reply Feb 19, 2022, 11:27 PM Reply Quote 1
    • K
      kellanist
      last edited by Mar 6, 2020, 9:33 PM

      How would I do something like Ctrl+Tab?

      R 1 Reply Last reply Mar 7, 2020, 2:34 AM Reply Quote 0
      • R
        Russ @kellanist
        last edited by Russ Mar 7, 2020, 2:35 AM Mar 7, 2020, 2:34 AM

        @kellanist, in theory this script would do it, but I don't have any app that would respond to CTRL-TAB, so I didn't test it.

        Dim Wsh
        Set Wsh = Wscript.CreateObject("Wscript.Shell")
        Wsh.SendKeys "^{TAB}"
        

        Russell VanderMey

        K 1 Reply Last reply Mar 7, 2020, 4:20 PM Reply Quote 0
        • K
          kellanist @Russ
          last edited by Mar 7, 2020, 4:20 PM

          @Russ Chrome! 😃

          Ctrl+tab = move to the next tab to the right.
          Ctrl+Shift+Tab = move to the previous tab to the left.
          Crtl+W = close tab.

          I use those programmed into my mouse to navigate around the browser.

          R 1 Reply Last reply Mar 7, 2020, 4:39 PM Reply Quote 0
          • R
            Russ @kellanist
            last edited by Russ Mar 7, 2020, 4:40 PM Mar 7, 2020, 4:39 PM

            @kellanist, duh, I use that CTRL-TAB key combo in chrome. It just didn't register in my brain.

            Anyway, I just tested it from my phone and it worked for me - my PC switched chrome tabs when I ran it. Let me know if it works for you please.

            Russell VanderMey

            K 2 Replies Last reply Mar 7, 2020, 4:44 PM Reply Quote 0
            • K
              kellanist @Russ
              last edited by Mar 7, 2020, 4:44 PM

              This post is deleted!
              1 Reply Last reply Reply Quote 0
              • K
                kellanist @Russ
                last edited by kellanist Mar 7, 2020, 5:53 PM Mar 7, 2020, 5:19 PM

                @Russ Ctrl+tab and Ctrl+Shift+Tab work perfectly.

                Ctrl+W for some odd reason causes Chome to close entirely instead of just closing a tab.

                I've tried "^(W)" and "^W" and they both close the window instead of a single tab. I'm a bit confused as to what is going.

                One other thing. Tried to setup Alt+Tab for switching windows and it works but triggers NUM lock for some odd reason. Using "%{TAB}".

                1 Reply Last reply Reply Quote 0
                • J
                  Jcjcc
                  last edited by Mar 22, 2020, 8:16 PM

                  Can you hold down a button?

                  R 1 Reply Last reply Mar 24, 2020, 6:24 PM Reply Quote 0
                  • R
                    Russ @Jcjcc
                    last edited by Mar 24, 2020, 6:24 PM

                    @Jcjcc, tell me more - what are you trying to accomplish?

                    Russell VanderMey

                    1 Reply Last reply Reply Quote 0
                    • D
                      Daniel Millan
                      last edited by May 30, 2020, 12:26 AM

                      Can I run this in a background command?

                      R 1 Reply Last reply May 30, 2020, 12:29 AM Reply Quote 0
                      • R
                        Russ @Daniel Millan
                        last edited by Russ May 30, 2020, 12:32 AM May 30, 2020, 12:29 AM

                        @Daniel-Millan, you could, but it wouldn't do any good. The command would run, but as Local System, not the user, so it wouldn't press any buttons for the logged in user.

                        If you make it a foreground command it might do what you're trying to accomplish though - you don't actually see the command running, you just see the results of the button(s) being pressed.

                        Russell VanderMey

                        D 1 Reply Last reply May 30, 2020, 12:33 AM Reply Quote 0
                        • D
                          Daniel Millan @Russ
                          last edited by May 30, 2020, 12:33 AM

                          @Russ I want to run it before I am logged into the computer.

                          R 1 Reply Last reply May 30, 2020, 12:54 AM Reply Quote 0
                          • R
                            Russ @Daniel Millan
                            last edited by May 30, 2020, 12:54 AM

                            @Daniel-Millan, don't think that's possible.

                            Russell VanderMey

                            D 1 Reply Last reply May 30, 2020, 1:03 AM Reply Quote 0
                            • D
                              Daniel Millan @Russ
                              last edited by May 30, 2020, 1:03 AM

                              @Russ
                              Okay, thanks.

                              R 1 Reply Last reply May 30, 2020, 1:06 AM Reply Quote 0
                              • R
                                Russ @Daniel Millan
                                last edited by Russ May 30, 2020, 1:07 AM May 30, 2020, 1:06 AM

                                @Daniel-Millan, sorry. I think it would be a security flaw to allow any process to simulate key presses at that point. That said, there might be some way to do it.

                                Russell VanderMey

                                1 Reply Last reply Reply Quote 0
                                • João Paulo PugialliJ
                                  João Paulo Pugialli
                                  last edited by Jun 30, 2020, 9:00 PM

                                  Hello,

                                  Do you know if it is possible to press a F-media key? For example, I wanted to make alexa press f9 key because that is my shorcut for keyboard lights off. I tried this code:

                                  Set WshShell = WScript.CreateObject("WScript.Shell")
                                  WshShell.SendKeys "{F9}"

                                  But it just keeps pressing numlock.

                                  Regards,

                                  R 1 Reply Last reply Jun 30, 2020, 10:29 PM Reply Quote 0
                                  • R
                                    Russ @João Paulo Pugialli
                                    last edited by Jun 30, 2020, 10:29 PM

                                    @João-Paulo-Pugialli, according to this article, {F9} is correct, so maybe your keyboard is doing something in hardware to toggle its own light off.
                                    https://social.technet.microsoft.com/wiki/contents/articles/5169.vbscript-sendkeys-method.aspx

                                    Russell VanderMey

                                    R 1 Reply Last reply Jul 25, 2020, 1:37 PM Reply Quote 1
                                    • R
                                      Russ @Russ
                                      last edited by Russ Jul 25, 2020, 1:38 PM Jul 25, 2020, 1:37 PM

                                      FYI, I found that Wsh.SendKeys can't do ALT+1 (or any other digit), but I was able to make it work with this AutoHotKey script.

                                      Send, !1
                                      

                                      ! means hold the ALT key (while pressing 1). You can see examples like this in the Tutorial page in AutoHotKey's help.

                                      My TRIGGERcmd command is this: start d:\tools\AutoHotKey\pressAlt1.ahk

                                      Let me know if you need me to do a video on this.

                                      Russell VanderMey

                                      1 Reply Last reply Reply Quote 0
                                      • Gerfesson Alves de OliveiraG
                                        Gerfesson Alves de Oliveira
                                        last edited by Aug 7, 2020, 12:07 AM

                                        How could I press windows key + "P" so I can open up the projection options?

                                        R 1 Reply Last reply Aug 7, 2020, 8:19 PM Reply Quote 0
                                        • R
                                          Russ @Gerfesson Alves de Oliveira
                                          last edited by Russ Aug 7, 2020, 8:20 PM Aug 7, 2020, 8:19 PM

                                          @Gerfesson-Alves-de-Oliveira, for this one I'd use AutoIT.

                                          I like AutoIT because it can do almost anything in Windows, and it allows you to compile your script to a stand-alone .EXE file. After you install it, look for SciTE Script Editor, that's the actual AutoIT script editor.

                                          You can see here how simple it is to make an AutoIT script that presses Windows+P:

                                          Send("{LWINDOWN}") ; Holds the Windows key down
                                          Send("{p}")       ; Presses the p key
                                          Send("{LWINUP}") ; Releases the Windows key
                                          

                                          This is a good reference page for pressing keys: https://www.autoitscript.com/autoit3/docs/appendix/SendKeys.htm

                                          Russell VanderMey

                                          Gerfesson Alves de OliveiraG TriboT 2 Replies Last reply Aug 8, 2020, 2:58 AM Reply Quote 0
                                          • First post
                                            Last post