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

    Press the Down Arrow key (or any other key)

    Windows
    17
    40
    13.9k
    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.
    • João Paulo PugialliJ
      João Paulo Pugialli
      last edited by

      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,

      RussR 1 Reply Last reply Reply Quote 0
      • RussR
        Russ @João Paulo Pugialli
        last edited by

        @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

        RussR 1 Reply Last reply Reply Quote 1
        • RussR
          Russ @Russ
          last edited by Russ

          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

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

            RussR 1 Reply Last reply Reply Quote 0
            • RussR
              Russ @Gerfesson Alves de Oliveira
              last edited by Russ

              @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 Reply Quote 0
              • Gerfesson Alves de OliveiraG
                Gerfesson Alves de Oliveira @Russ
                last edited by

                @Russ , I found a way thru your guidence!! Thanks a lot!

                The whole au3 document was this:

                Send("{LWINDOWN}") ; Holds the Windows key down
                Send("{p}") ; Presses the p key
                Send("{LWINUP}") ; Releases the Windows key
                sleep (500)
                Send("{UP}") ; Presses Up arrow
                Send("{ENTER}") ; Presses Enter
                sleep(500)
                ShellExecute("C:\Users\nosse\AppData\Local\Programs\Opera GX\launcher.exe")
                ShellExecute("https://www.primevideo.com")
                ShellExecute("https://www.netflix.com")
                sleep (2000)
                Send("^{TAB}") ; Presses Shift + Tab
                Send("{CTRLDOWN}") ; Holds the CTRL key down
                Send("{w}") ; Presses the w key
                Send("{CTRLUP}") ; Releases the CTRL key
                sleep (300)
                Send("{ENTER}") ; Presses Enter
                Send("{LWINDOWN}") ; Holds the Windows key down
                Send("{SHIFTDOWN}") ; Holds the Left Shift key down
                Send("{RIGHT}") ; Presses Right arrow
                Send("{SHIFTUP}") ; Releases the Shift key
                Send("{LWINUP}") ; Releases the Windows key

                With this code I change the screen mode to extend the for my projector, open up a new opera window with netflix and prime video, close the opera's welcome window and finally put this new openned window to the second screen!

                Now I'm going to do the reverse engineering! Thanks a lot once again

                RussR 1 Reply Last reply Reply Quote 0
                • RussR
                  Russ @Gerfesson Alves de Oliveira
                  last edited by

                  @Gerfesson-Alves-de-Oliveira, nice job!

                  I hope you do a youtube video showing it off.

                  Russell VanderMey

                  1 Reply Last reply Reply Quote 0
                  • Andoni CantónA
                    Andoni Cantón
                    last edited by

                    how can I make it press the spacebar? I'm trying to get it to play or pause netflix or youtube

                    RussR 1 Reply Last reply Reply Quote 0
                    • RussR
                      Russ @Andoni Cantón
                      last edited by

                      @Andoni-Cantón said in Press the Down Arrow key (or any other key):

                      space

                      @Andoni-Cantón, for space, you can use this script:

                      Dim Wsh
                      Set Wsh = Wscript.CreateObject("Wscript.Shell")
                      Wsh.SendKeys " "
                      

                      You can run the script with this command:

                      wscript c:\scripts\space.vbs
                      

                      Russell VanderMey

                      Teo castrejon escamillaT 1 Reply Last reply Reply Quote 0
                      • TriboT
                        Tribo @Russ
                        last edited by

                        @Russ said in Press the Down Arrow key (or any other key):

                        @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

                        I added:

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

                        but it didn't happen as expected (using AutoIt's F5), it applies the three commands in AutoIt's own window.

                        it's the first time I've seen and dealt with it, so sorry for any silly question.

                        RussR 1 Reply Last reply Reply Quote 0
                        • RussR
                          Russ @Tribo
                          last edited by

                          @Tribo, with AutoIT you can compile an EXE, and when you run the exe via TRIGGERcmd, the keys will be pressed in whatever the current application happens to be. You can also have AutoIT activate a particular Window first.

                          https://www.autoitscript.com/autoit3/docs/functions/WinActivate.htm

                          Russell VanderMey

                          1 Reply Last reply Reply Quote 0
                          • Arthur NeufeldA
                            Arthur Neufeld
                            last edited by Arthur Neufeld

                            I really don't know what I did wrong.

                            They only thing I want is to let Triggercmd press F7.

                            I created a vbs file with

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

                            in it. Safed it at

                            c:\scripts\key.vbs
                            

                            Then I wrote this into the "Command" line: in TRIGGERcmd

                            wscript c:\scripts\key.vbs
                            

                            Even if I ope the File manually it doesn't press F7. I have to say, I'm really new to this topic.
                            What did I do wrong?

                            Cheers
                            Arthur

                            RussR 1 Reply Last reply Reply Quote 0
                            • RussR
                              Russ @Arthur Neufeld
                              last edited by

                              @Arthur-Neufeld, that should work. It worked for me. Can you show me a screenshot of your command?

                              Mine looks like this:

                              4b240459-5018-466b-be24-fa912d50231b-image.png

                              Also, does it work if you run the command from a cmd prompt?

                              Russell VanderMey

                              Arthur NeufeldA 1 Reply Last reply Reply Quote 0
                              • XanderX
                                Xander
                                last edited by

                                Haven't tried this feature myself but Nirsoft's NirCMD has a "sendkeypress" ability.
                                https://www.nirsoft.net/utils/nircmd2.html#using

                                Here's my question though -- how does your VBS script send the keypress to the right window or, on your PC, is F7 being recognized by one program no matter what program is in the foreground?

                                Nircmd has a WIN feature which lets you activate a window so you could use it twice in a new script, once to activate the window and again to send the keypress.

                                1 Reply Last reply Reply Quote 1
                                • Arthur NeufeldA
                                  Arthur Neufeld @Russ
                                  last edited by

                                  @Russ Hi Russ, no unfortunately it doesn't rund the command from a cmd prompt. This happens if I copy and paste it in cmd:

                                  https://www.dropbox.com/s/se4b59gxgk43su2/Screenshot 2021-01-26 19.25.19.png?dl=0

                                  The command looks exactly like yours:

                                  https://www.dropbox.com/s/a1b2parwrkjf848/Screenshot 2021-01-26 19.20.48.png?dl=0

                                  The F7 Button is a Hotkey for a Streaming Software called OBS to change the Scene. Does that matter?

                                  Thanks for your help already

                                  RussR 1 Reply Last reply Reply Quote 0
                                  • RussR
                                    Russ @Arthur Neufeld
                                    last edited by Russ

                                    @Arthur-Neufeld, I'm glad you mentioned OBS. I had no luck using wscript to send hot keys to OBS, so I made this post where I made two AutoIT .exe files - one for start recording, and one for stop recording, but you could use them for start and stop streaming too.

                                    I use them and it works great.

                                    Russell VanderMey

                                    1 Reply Last reply Reply Quote 0
                                    • Antonio LeañosA
                                      Antonio Leaños
                                      last edited by

                                      Hey I used this and it works just fine, but I want to use the start /wait timeout command to give some space in between a couple key presses but it just ignores them and say "access denied" does anyone know why is that?
                                      Thanks

                                      RussR 1 Reply Last reply Reply Quote 0
                                      • RussR
                                        Russ @Antonio Leaños
                                        last edited by

                                        @Antonio-Leaños, when I tried a command like this, it worked for me.

                                        start /min /wait timeout 5 & calc
                                        

                                        It waited 5 seconds, then ran calculator.

                                        Does that work for you? If not, can you tell me what command you're trying?

                                        Russell VanderMey

                                        1 Reply Last reply Reply Quote 0
                                        • Teo castrejon escamillaT
                                          Teo castrejon escamilla @Russ
                                          last edited by

                                          @russ said in Press the Down Arrow key (or any other key):

                                          wscript c:\scripts\space.vbs

                                          does it work on mac?

                                          RussR 1 Reply Last reply Reply Quote 0
                                          • RussR
                                            Russ @Teo castrejon escamilla
                                            last edited by

                                            @teo-castrejon-escamilla , no. On Mac you could use applescript.

                                            https://apple.stackexchange.com/questions/36943/how-do-i-automate-a-key-press-in-applescript

                                            Russell VanderMey

                                            1 Reply Last reply Reply Quote 0
                                            • First post
                                              Last post