corriganc Posted August 1, 2018 Posted August 1, 2018 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!FYI, here is the AutoHotKey that I'm trying to get this script to interact with: expandcollapse popup; GLOBAL SETTINGS =============================================================================================================== ;#Warn #NoEnv #SingleInstance Force SetBatchLines -1 #Include Class_NvAPI.ahk ; SCRIPT ======================================================================================================================== OnExit, EOF NVIDIA := 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 Thank you.
Moderators Melba23 Posted August 1, 2018 Moderators Posted August 1, 2018 Moved to the appropriate forum. Moderation Team Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
Moderators Melba23 Posted August 1, 2018 Moderators Posted August 1, 2018 corriganc, As you are using an AHK script, probably best to ask on the an AHK forum - this one is for AutoIt-related questions. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
corriganc Posted August 1, 2018 Author Posted August 1, 2018 Melba23, I did look into this originally, but read that AutoIT was a good solution for keypresses, over AHK and VBS/BAT - not sure why this was, but I didn't want to argue with the internet due to my "0 clues" I will post this on AHK also, but if you do know of a way to press Win+[NP]5 that'd be great!
xcaliber13 Posted August 1, 2018 Posted August 1, 2018 corriganc look in the help file Send command and also in the help file Send Key List. This will answer your question
corriganc Posted August 1, 2018 Author Posted August 1, 2018 9 minutes ago, xcaliber13 said: corriganc look in the help file Send command and also in the help file Send Key List. This will answer your question Hi there, I've done this and have come up with the following: Send("{LWIN down}") ; Holds the Win key down ; Sleep for 5 seconds. Sleep(1000) Send("{NUMPAD5}") ; Presses Numpad 5 ; Sleep for 5 seconds. Sleep(1000) Send("{LWIN up}") ; Releases the Win key But the issue I have is, it doesn't seem to hold the Win key down initially, instead of pressing it. This is visible when the start menu appears with the number 5 typed into it. However, it then appears to be infinitely holding the Win key after that, as every other key I manually press on my keyboard then performs the Win+ function associated with it. I tried it with and without the sleep commands, still the same.
xcaliber13 Posted August 1, 2018 Posted August 1, 2018 More like this Send({LWINDOWN}{NUMPAD5}) this will press the windows key and the number pad 5 key
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now