Jump to content

Recommended Posts

Posted

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:

; 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
Posted

Moved to the appropriate forum.

Moderation Team

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

  • Moderators
Posted

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Posted

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!

Posted
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.

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...