Script to emulate specific key presses needed

Page 1 of 2 12 LastLast

  1. Posts : 9
    Windows 10 Pro b.1803
       #1

    Script to emulate specific key presses needed


    Hello all,

    I appreciate this is a big ask, but I have absolutely 0 clues what I'm doing!

    I need a simple batch or VBS script that will wait 20 seconds after login and then virtually press and hold the Win Key and then the Numpad 5 key.

    I have an AutoHotKey script that requires me to press Win+[NP]5 to apply its settings, but I'd much rather have it just apply automatically at login (once the AHK script has loaded - hence the 20-second wait).

    Any help anyone can provide is greatly appreciated!

    Hoping we've got some master coders in here!

    Thank you.
      My Computer


  2. Posts : 42,893
    Win 10 Pro (22H2) (2nd PC is 22H2)
       #2

    If you have a AHK script, why not modify that? (I'm assuming you have the source code- the script- a xxxx.ahk file (which you can open in Notepad e.g.) rather than a xxxx.exe compiled from a xxxx.ahk file).

    Otherwise- and this is a bit silly in that context- you'd need to write a tiny AHK script launched on startup that loops waiting for that AHK script to run, then sends the characters to the script.

    I'd suggest you modify the original script.
      My Computers


  3. Posts : 9
    Windows 10 Pro b.1803
    Thread Starter
       #3

    [QUOTE=dalchina;1426977]If you have a AHK script, why not modify that? (I'm assuming you have the source code- the script- a xxxx.ahk file (which you can open in Notepad e.g.) rather than a xxxx.exe compiled from a xxxx.ahk file).

    Hi there,

    Thanks for this. Do you, by chance, know what code I would need to write?

    FYI, here's the full AHK script:
    ; GLOBAL SETTINGS ==================================================================================================== ===========;#Warn#NoEnv#SingleInstance ForceSetBatchLines -1#Include Class_NvAPI.ahk; SCRIPT ==================================================================================================== ====================OnExit, EOFNVIDIA := new NvAPI()def := NVIDIA.GetDVCInfoEx(0).defaultLevel; Win + Numpad 4 (or Numpad Left) ==> Decrease Digital Vibrance by 1#Numpad4:: NVIDIA.SetDVCLevelEx((DV := NVIDIA.GetDVCInfoEx(0).currentLevel - 1) > 100 ? 100 : DV < 0 ? 0 : DV, 0)#NumpadLeft:: NVIDIA.SetDVCLevelEx((DV := NVIDIA.GetDVCInfoEx(0).currentLevel - 1) > 100 ? 100 : DV < 0 ? 0 : DV, 0); Win + Numpad 5 (or Numpad Clear) ==> Set Digital Vibrance to Default (50)#Numpad5:: NVIDIA.SetDVCLevelEx(def, 0)#NumpadClear:: NVIDIA.SetDVCLevelEx(def, 0); Win + Numpad 6 (or Numpad Right) ==> Increase Digital Vibrance by 1#Numpad6:: NVIDIA.SetDVCLevelEx((DV := NVIDIA.GetDVCInfoEx(0).currentLevel + 1) > 100 ? 100 : DV < 0 ? 0 : DV, 0)#NumpadRight:: NVIDIA.SetDVCLevelEx((DV := NVIDIA.GetDVCInfoEx(0).currentLevel + 1) > 100 ? 100 : DV < 0 ? 0 : DV, 0); Win + Numpad 8 (or Numpad UpArrow) ==> Set Digital Vibrance to 80#Numpad8:: NVIDIA.SetDVCLevelEx(80, 0)#NumpadUp:: NVIDIA.SetDVCLevelEx(80, 0); EXIT ==================================================================================================== ======================GuiClose:EOF:NVIDIA.SetDVCLevelEx(def, 0)NVIDIA.OnExit()ExitApp
    Hoping you can help!

    Thank you
      My Computer


  4. Posts : 42,893
    Win 10 Pro (22H2) (2nd PC is 22H2)
       #4

    Well, that looks a complex script because it is not in a readable form.
    It's as if all the white space (spaces, new lines etc) have been deleted.
    Actually it seems that it simply assigns a number of functions to different hotkeys.

    No, I'm not going to try to write you a script, sorry, but if you download and install Autohotkey, it has a huge well-organised help file with examples for each command.

    Why does that script need a particular key press? Can you not modify it so the script simply runs and does what pressing that key would do?

    Win + Numpad 5 (or Numpad Clear) ==> Set Digital Vibrance to Default (50)
    #Numpad5:: NVIDIA.SetDVCLevelEx(def, 0)

    That's the line you're interested in... but I can't understand what it's doing (the right half)

    Can you upload the AHK file, 'cos that one's unreadable. Thanks.
      My Computers


  5. Posts : 9
    Windows 10 Pro b.1803
    Thread Starter
       #5

    Hi again,

    The AHK file is modigying the Digital Vibrance Settings in the Nvidia Control Panel.

    Win+5 specifically is setting it to 50 (/100).

    As requested, I've included the file.

    Thank you.
    Script to emulate specific key presses needed Attached Files
      My Computer


  6. Posts : 42,893
    Win 10 Pro (22H2) (2nd PC is 22H2)
       #6

    I think you got the script here:
    https://autohotkey.com/boards/viewto...=5508&start=40

    I can give you a script that will send the key sequence to it tomorrow. How you launch that (2 lines) is then up to you.

    I could guess how to modify the existing script to simply do that function without the keys, but to be honest, I don't understand it well enough. I understand its structure, rather than what it does, but I wouldn't test it myself.
      My Computers


  7. Posts : 9
    Windows 10 Pro b.1803
    Thread Starter
       #7

    dalchina said:
    I think you got the script here:
    https://autohotkey.com/boards/viewto...=5508&start=40

    I can give you a script that will send the key sequence to it tomorrow. How you launch that (2 lines) is then up to you.

    I could guess how to modify the existing script to simply do that function without the keys, but to be honest, I don't understand it well enough. I understand its structure, rather than what it does, but I wouldn't test it myself.
    That would be great, thank you.
      My Computer


  8. Posts : 42,893
    Win 10 Pro (22H2) (2nd PC is 22H2)
       #8

    Here's a pair of demo scripts - run the Nvidia-DV.ahk from this (not your original), then try typing the different key combos. You should get an appropriate message. (Edit Nvidia-DV.ahk to see what's there).

    Then you can run Sendkey.ahk which sends Win key NumpadClear.

    When happy, try Sendkey.ahk with your original running.

    A better way to achieve what you want (have vibrance set when you log on) would be to have that instruction executed when the script is run- i.e. modify it to add that to happen at the start of the script. Then you don't need to fiddle around emulating key presses.
    Script to emulate specific key presses needed Attached Files
      My Computers


  9. Posts : 42,893
    Win 10 Pro (22H2) (2nd PC is 22H2)
       #9

    I'll put this in a separate post to clearly distinguish it.

    Here I've added a bit to the script which may work - try it.
    This is meant to do the same as pressing win key + Numpad clear - when the script is run.

    If it works, no need to mess around sending key sequences to a script.

    You could always post in the Autohotkey forum to ask about this.
    Script to emulate specific key presses needed Attached Files
      My Computers


  10. Posts : 9
    Windows 10 Pro b.1803
    Thread Starter
       #10

    dalchina said:
    i'll put this in a separate post to clearly distinguish it.

    Here i've added a bit to the script which may work - try it.
    This is meant to do the same as pressing win key + numpad clear - when the script is run.

    If it works, no need to mess around sending key sequences to a script.

    You could always post in the autohotkey forum to ask about this.
    brilliant, thank you!!!
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 05:34.
Find Us




Windows 10 Forums