AutoHotkey & NVIDIA (NvAPI)

Post your working scripts, libraries and tools
User avatar
jNizM
Posts: 2662
Joined: 30 Sep 2013, 01:33
GitHub: jNizM
Contact:

Re: AutoHotkey & NVIDIA (NvAPI)

24 Aug 2015, 01:45

@Azevedo:
Saturation (aka Digital Vibrance) currently works already. (See examples in this thread)
For brightness & contrast, I will look into it.

@Vols and Jezuz
I will look into it.
[AHK] 1.1.32.00 x64 Unicode | [WIN] 10 Pro (Version 2004) x64 | [GitHub] Profile
Donations are appreciated if I could help you
Vols and Jezuz
Posts: 5
Joined: 13 Feb 2015, 02:53

Re: AutoHotkey & NVIDIA (NvAPI)

24 Aug 2015, 01:55

I found some old NvAPI documentation that has some information on the NvAPI_GPU_SetCoolerLevels function that may be helpful (this and many other functions aren't covered in new documentation for some reason):

http://evolution3d.googlecode.com/svn/t ... pi/nvapi.h

One important thing to note is that the cooler policy must be set to manual in order to set a fan %. I'm not sure why I can't get it working treating it like you treated other functions in your library. I'm probably missing something in the details. Thanks for looking into it.
Azevedo
Posts: 81
Joined: 07 Feb 2014, 11:35

Re: AutoHotkey & NVIDIA (NvAPI)

24 Aug 2015, 11:55

jNizM:
That would be amazing!!!
I'll wait for it!
User avatar
jNizM
Posts: 2662
Joined: 30 Sep 2013, 01:33
GitHub: jNizM
Contact:

Re: AutoHotkey & NVIDIA (NvAPI)

25 Aug 2015, 06:30

GPU_SetCoolerLevels: (just quick and dirty - need to test it more later)

Code: Select all

; ###############################################################################################################################

    GPU_SetCoolerLevels(currentLevel, currentPolicy := 1, hPhysicalGpu := 0)
    {
        static NVAPI_MAX_COOLERS_PER_GPU := 20
        static NV_GPU_SETCOOLER_LEVEL    := 4 + (8 * NVAPI_MAX_COOLERS_PER_GPU)
        if !(hPhysicalGpu)
            hPhysicalGpu := NvAPI.EnumPhysicalGPUs().1
        VarSetCapacity(pCoolerLevels, NV_GPU_SETCOOLER_LEVEL, 0)
        , NumPut(NV_GPU_SETCOOLER_LEVEL | 0x10000, pCoolerLevels, 0, "UInt")
        , NumPut(currentLevel,                     pCoolerLevels, 4, "UInt")
        , NumPut(currentPolicy,                    pCoolerLevels, 8, "UInt")
        if !(NvStatus := DllCall(NvAPI._GPU_SetCoolerLevels, "Ptr", hPhysicalGpu, "UInt", 7, "Ptr", &pCoolerLevels, "CDECL"))
            return True
        return "*" NvStatus
    }

; ###############################################################################################################################
For testing:

Code: Select all

; GLOBAL SETTINGS ===============================================================================================================

;#Warn
#NoEnv
#SingleInstance Force
SetBatchLines -1
#Include Class_NvAPI.ahk

; SCRIPT ========================================================================================================================

OnExit, EOF
NVIDIA := new NvAPI()

MsgBox % "GPU_GetCoolerSettings().version:`t`t"     NVIDIA.GPU_GetCoolerSettings().version               "`n"
. "GPU_GetCoolerSettings().count:`t`t"              NVIDIA.GPU_GetCoolerSettings().count                 "`n"
. "GPU_GetCoolerSettings().1.type:`t`t"             NVIDIA.GPU_GetCoolerSettings().1.type                "`n"
. "GPU_GetCoolerSettings().1.controller:`t`t"       NVIDIA.GPU_GetCoolerSettings().1.controller          "`n"
. "GPU_GetCoolerSettings().1.defaultMinLevel:`t"    NVIDIA.GPU_GetCoolerSettings().1.defaultMinLevel     "`n"
. "GPU_GetCoolerSettings().1.defaultMaxLevel:`t"    NVIDIA.GPU_GetCoolerSettings().1.defaultMaxLevel     "`n"
. "GPU_GetCoolerSettings().1.currentMinLevel:`t"    NVIDIA.GPU_GetCoolerSettings().1.currentMinLevel     "`n"
. "GPU_GetCoolerSettings().1.currentMaxLevel:`t"    NVIDIA.GPU_GetCoolerSettings().1.currentMaxLevel     "`n"
. "GPU_GetCoolerSettings().1.currentLevel:`t`t"     NVIDIA.GPU_GetCoolerSettings().1.currentLevel        "`n"
. "GPU_GetCoolerSettings().1.defaultPolicy:`t`t"    NVIDIA.GPU_GetCoolerSettings().1.defaultPolicy       "`n"
. "GPU_GetCoolerSettings().1.currentPolicy:`t`t"    NVIDIA.GPU_GetCoolerSettings().1.currentPolicy       "`n"
. "GPU_GetCoolerSettings().1.target:`t`t"           NVIDIA.GPU_GetCoolerSettings().1.target              "`n"
. "GPU_GetCoolerSettings().1.controlType:`t`t"      NVIDIA.GPU_GetCoolerSettings().1.controlType         "`n"
. "GPU_GetCoolerSettings().1.active:`t`t"           NVIDIA.GPU_GetCoolerSettings().1.active              "`n"
. "GPU_GetCoolerSettings().1.speedRPM:`t`t"         NVIDIA.GPU_GetCoolerSettings().1.speedRPM            "`n"
. "GPU_GetCoolerSettings().1.bSupported:`t`t"       NVIDIA.GPU_GetCoolerSettings().1.bSupported          "`n"
. "GPU_GetCoolerSettings().1.maxSpeedRPM:`t"        NVIDIA.GPU_GetCoolerSettings().1.maxSpeedRPM         "`n"
. "GPU_GetCoolerSettings().1.minSpeedRPM:`t"        NVIDIA.GPU_GetCoolerSettings().1.minSpeedRPM         "`n"

NVIDIA.GPU_SetCoolerLevels(50, 1)    ; 1 = MANUAL
sleep 1000

MsgBox % "GPU_GetCoolerSettings().version:`t`t"     NVIDIA.GPU_GetCoolerSettings().version               "`n"
. "GPU_GetCoolerSettings().count:`t`t"              NVIDIA.GPU_GetCoolerSettings().count                 "`n"
. "GPU_GetCoolerSettings().1.type:`t`t"             NVIDIA.GPU_GetCoolerSettings().1.type                "`n"
. "GPU_GetCoolerSettings().1.controller:`t`t"       NVIDIA.GPU_GetCoolerSettings().1.controller          "`n"
. "GPU_GetCoolerSettings().1.defaultMinLevel:`t"    NVIDIA.GPU_GetCoolerSettings().1.defaultMinLevel     "`n"
. "GPU_GetCoolerSettings().1.defaultMaxLevel:`t"    NVIDIA.GPU_GetCoolerSettings().1.defaultMaxLevel     "`n"
. "GPU_GetCoolerSettings().1.currentMinLevel:`t"    NVIDIA.GPU_GetCoolerSettings().1.currentMinLevel     "`n"
. "GPU_GetCoolerSettings().1.currentMaxLevel:`t"    NVIDIA.GPU_GetCoolerSettings().1.currentMaxLevel     "`n"
. "GPU_GetCoolerSettings().1.currentLevel:`t`t"     NVIDIA.GPU_GetCoolerSettings().1.currentLevel        "`n"
. "GPU_GetCoolerSettings().1.defaultPolicy:`t`t"    NVIDIA.GPU_GetCoolerSettings().1.defaultPolicy       "`n"
. "GPU_GetCoolerSettings().1.currentPolicy:`t`t"    NVIDIA.GPU_GetCoolerSettings().1.currentPolicy       "`n"
. "GPU_GetCoolerSettings().1.target:`t`t"           NVIDIA.GPU_GetCoolerSettings().1.target              "`n"
. "GPU_GetCoolerSettings().1.controlType:`t`t"      NVIDIA.GPU_GetCoolerSettings().1.controlType         "`n"
. "GPU_GetCoolerSettings().1.active:`t`t"           NVIDIA.GPU_GetCoolerSettings().1.active              "`n"
. "GPU_GetCoolerSettings().1.speedRPM:`t`t"         NVIDIA.GPU_GetCoolerSettings().1.speedRPM            "`n"
. "GPU_GetCoolerSettings().1.bSupported:`t`t"       NVIDIA.GPU_GetCoolerSettings().1.bSupported          "`n"
. "GPU_GetCoolerSettings().1.maxSpeedRPM:`t"        NVIDIA.GPU_GetCoolerSettings().1.maxSpeedRPM         "`n"
. "GPU_GetCoolerSettings().1.minSpeedRPM:`t"        NVIDIA.GPU_GetCoolerSettings().1.minSpeedRPM         "`n"

NVIDIA.GPU_SetCoolerLevels(50, 8)    ; 8 = CONTINUOUS_HW (default Policy for me)

; EXIT ==========================================================================================================================

GuiClose:
EOF:
NVIDIA.OnExit()
ExitApp
[AHK] 1.1.32.00 x64 Unicode | [WIN] 10 Pro (Version 2004) x64 | [GitHub] Profile
Donations are appreciated if I could help you
User avatar
jNizM
Posts: 2662
Joined: 30 Sep 2013, 01:33
GitHub: jNizM
Contact:

Re: AutoHotkey & NVIDIA (NvAPI)

25 Aug 2015, 07:12

Did you use the whole class with this function included?

Beta Link: Class_NvAPI.ahk
ImageImage
[AHK] 1.1.32.00 x64 Unicode | [WIN] 10 Pro (Version 2004) x64 | [GitHub] Profile
Donations are appreciated if I could help you
Vols and Jezuz
Posts: 5
Joined: 13 Feb 2015, 02:53

Re: AutoHotkey & NVIDIA (NvAPI)

25 Aug 2015, 15:53

I didn't see this mentioned, but you also have to add this to the first part of the Class_NvApi.ahk ... EDIT: Just naw saw the beta link where you did this.

Code: Select all

				NvAPI._GPU_SetCoolerLevels					:= DllCall(NvAPI.DllFile "\nvapi_QueryInterface", "UInt", 0x891FA0AE, "CDECL UPtr")
But it's working great, thanks for looking into that. You are a god. I'm adding a feature utilizing this to my program.
Azevedo
Posts: 81
Joined: 07 Feb 2014, 11:35

Re: AutoHotkey & NVIDIA (NvAPI)

25 Aug 2015, 16:01

jNizM: oh I missed Class_NvAPI.ahk

Now it works :)

I'm anxious for the bright/contrast API.

Thanks
User avatar
jNizM
Posts: 2662
Joined: 30 Sep 2013, 01:33
GitHub: jNizM
Contact:

Re: AutoHotkey & NVIDIA (NvAPI)

26 Aug 2015, 05:04

- Saturation (Digital vibrance) was already added => see GetDVCInfoEx / SetDVCInfoEx or 3rd example in first post.
- Hue added (see beta link => GetHUEInfo / SetHUEInfo)

- Brightness & Contrast are a bit more complicated. I would currently recommend Class Monitor (Brightness, Contrast, Gamma)
[AHK] 1.1.32.00 x64 Unicode | [WIN] 10 Pro (Version 2004) x64 | [GitHub] Profile
Donations are appreciated if I could help you
User avatar
jNizM
Posts: 2662
Joined: 30 Sep 2013, 01:33
GitHub: jNizM
Contact:

Re: AutoHotkey & NVIDIA (NvAPI)

26 Nov 2015, 03:16

Added in latest beta (link in first post):
* DisableHWCursor()
* DRS_CreateSession()
* DRS_DestroySession()
* DRS_GetCurrentGlobalProfile()
* DRS_GetNumProfiles()
* DRS_LoadSettings()
* DRS_LoadSettingsFromFile()
* DRS_RestoreAllDefaults()
* DRS_SaveSettings()
* DRS_SaveSettingsToFile()
* EnableHWCursor()
* EnumLogicalGPUs()
* GetErrorMessage()
* GetHUEInfo()
* GPU_GetHDCPSupportStatus()
* GPU_GetOutputType()
* GPU_SetCoolerLevels()
* SetHUEAngle()

Added more (in beta):
* GetDisplayPortInfo()
* GetHDMISupportInfo()

Added more (in beta):
* VIO_EnumDevices()
* VIO_GetCapabilities()
* VIO_IsRunning()
* VIO_Start()
* VIO_Stop()
[AHK] 1.1.32.00 x64 Unicode | [WIN] 10 Pro (Version 2004) x64 | [GitHub] Profile
Donations are appreciated if I could help you
User avatar
jNizM
Posts: 2662
Joined: 30 Sep 2013, 01:33
GitHub: jNizM
Contact:

Re: AutoHotkey & NVIDIA (NvAPI)

01 Dec 2015, 06:01

New in latest Beta (link in first post):
* __New() to static init := NvAPI.ClassInit()
* __Delete() to static DELFunc := OnExit(ObjBindMethod(NvAPI, "_Delete"))
* nvapi_QueryInterface (GetProcAddress) is now in every function
* static ErrorMessage := False (False for Error Code | True for Error Message)
[AHK] 1.1.32.00 x64 Unicode | [WIN] 10 Pro (Version 2004) x64 | [GitHub] Profile
Donations are appreciated if I could help you
robhayes
Posts: 19
Joined: 28 Dec 2015, 15:35

Re: AutoHotkey & NVIDIA (NvAPI)

02 Jan 2016, 12:07

I'd also love to be able to control Nvidia Surround with this.
McSwingles
Posts: 64
Joined: 17 Oct 2015, 15:23

Re: AutoHotkey & NVIDIA (NvAPI)

03 Jan 2016, 19:19

How about the setting that controls the gpu temp limit to prevent it from going past a certain temperature like afterburner has? I see temparture in the first post but I don't know if it's configurable or not.
User avatar
jNizM
Posts: 2662
Joined: 30 Sep 2013, 01:33
GitHub: jNizM
Contact:

Re: AutoHotkey & NVIDIA (NvAPI)

31 Mar 2016, 09:20

Status Update:
* Support for Multi-GPU is half-finished
[AHK] 1.1.32.00 x64 Unicode | [WIN] 10 Pro (Version 2004) x64 | [GitHub] Profile
Donations are appreciated if I could help you
Demerzel8008

Re: AutoHotkey & NVIDIA (NvAPI)

09 Aug 2016, 06:32

in the ahk script. How do i change it to affect monitor 2?
User avatar
jNizM
Posts: 2662
Joined: 30 Sep 2013, 01:33
GitHub: jNizM
Contact:

Re: AutoHotkey & NVIDIA (NvAPI)

09 Aug 2016, 07:21

More detailed information please!
[AHK] 1.1.32.00 x64 Unicode | [WIN] 10 Pro (Version 2004) x64 | [GitHub] Profile
Donations are appreciated if I could help you
Guest

Re: AutoHotkey & NVIDIA (NvAPI)

09 Aug 2016, 07:58

I have 2 monitors

1. DP 1440p monitor
2. HDMI 1080p monitor for gaming

The ahk script for vibrance is copy pasted from your link
It only affects monitor 1.
User avatar
jNizM
Posts: 2662
Joined: 30 Sep 2013, 01:33
GitHub: jNizM
Contact:

Re: AutoHotkey & NVIDIA (NvAPI)

09 Aug 2016, 08:06

Tested with 2 monitors (22" & 19") and no problem here

Code: Select all

AHK Version ...: 1.1.24.01 x64 Unicode
Win Version ...: Windows 10 Pro Version 1607 (Build 14393.10)

Code: Select all

; ===============================================================================================================================
; Title .........: NvAPI GUI SetDVC
; AHK Version ...: 1.1.24.01 x64 Unicode
; Win Version ...: Windows 10 Pro Version 1607 (Build 14393.10)
; Description ...: NvAPI GUI SetDVC
; Version .......: v1.03
; Modified ......: 2016.08.01-2113
; Author(s) .....: jNizM
; ===============================================================================================================================
;@Ahk2Exe-SetName NvAPI GUI SetDVC
;@Ahk2Exe-SetDescription NvAPI GUI SetDVC
;@Ahk2Exe-SetVersion v1.03
;@Ahk2Exe-SetCopyright Copyright (c) 2014-2016`, jNizM
;@Ahk2Exe-SetOrigFilename Class_NvAPI_GUI_SetDVC.ahk
; ===============================================================================================================================

; GLOBAL SETTINGS ===============================================================================================================

#NoEnv
#SingleInstance Force
SetBatchLines -1

#Include Class_NvAPI.ahk

; GUI ===========================================================================================================================

cnt := 0, arrCur := [], arrDef := []

while (NvAPI.EnumNvidiaDisplayHandle(cnt) != "*-7")
{
    arrCur.Push(NvAPI.GetDVCInfoEx(cnt).currentLevel)
    arrDef.Push(NvAPI.GetDVCInfoEx(cnt).defaultLevel)
    ++cnt
}

gbh := 93 + 27 * (cnt - 1)

Gui, Margin, 5, 5
Gui, Font, s16 w800 q4 c76B900, MS Shell Dlg 2
Gui, Add, Text, xm ym w240 0x201, % NvAPI.GPU_GetFullName()

Gui, Font, s9 w400 q1 c000000, MS Shell Dlg 2
Gui, Add, GroupBox, xm y+10 w240 h%gbh%, % "Digital Vibrance Control (DVC)"

Gui, Add, Text, xm+11 ym+60 w60 h22 0x0200, % "Display #1"
Gui, Add, Edit, x+10 yp w80 h22 0x2002 Limit3 vDVCS1, % arrCur[1]
Gui, Font, s9 w400 q1 csilver, MS Shell Dlg 2
Gui, Add, Text, x+10 yp w60 h22 0x0200, % "(0 - 100)"

loop % arrCur.MaxIndex() - 1
{
    cur := A_Index + 1
    Gui, Font, s9 w400 q1 c000000, MS Shell Dlg 2
    Gui, Add, Text, xm+11 y+5 w60 h22 0x0200, % "Display #" cur
    Gui, Add, Edit, x+10 yp w80 h22 0x2002 Limit3 vDVCS%cur%, % arrCur[cur]
    Gui, Font, s9 w400 q1 csilver, MS Shell Dlg 2
    Gui, Add, Text, x+10 yp w60 h22 0x0200, % "(0 - 100)"
}

Gui, Add, Button, xm+10 y+10 w60 gDVCSet, % "Set"
Gui, Add, Button, x+10 yp w60 gDVCReset, % "Reset"

Gui, Show, AutoSize

return

; UPDATE ========================================================================================================================

DVCSet:
    Gui, Submit, NoHide
    loop % arrCur.MaxIndex()
    {
        DVCS := DVCS%A_Index% > 100 ? 100 : DVCS%A_Index% < 0 ? 0 : DVCS%A_Index%
        NvAPI.SetDVCLevelEx(DVCS, A_Index - 1)
        GuiControl,, DVCS%A_Index%, % DVCS
    }
return

DVCReset:
    loop % arrDef.MaxIndex()
    {
        NvAPI.SetDVCLevelEx(arrDef[A_Index], A_Index - 1)
        GuiControl,, DVCS%A_Index%, % arrCur[A_Index]
    }
return

; EXIT ==========================================================================================================================

GuiClose:
GuiEscape:
ExitApp
[AHK] 1.1.32.00 x64 Unicode | [WIN] 10 Pro (Version 2004) x64 | [GitHub] Profile
Donations are appreciated if I could help you
Guest

Re: AutoHotkey & NVIDIA (NvAPI)

09 Aug 2016, 08:25

rebooted computer and he ahk script stardet working on the monitor 2 instead of 1 ;) wich is what i wanted. Not sure of why.

The last code you posted, thanks but i dont understad what to do with it.
I understand making hotkeys and including.. not much beyond that.
User avatar
jNizM
Posts: 2662
Joined: 30 Sep 2013, 01:33
GitHub: jNizM
Contact:

Re: AutoHotkey & NVIDIA (NvAPI)

09 Aug 2016, 08:34

The code I posted was the GUI Version
Image
[AHK] 1.1.32.00 x64 Unicode | [WIN] 10 Pro (Version 2004) x64 | [GitHub] Profile
Donations are appreciated if I could help you

Return to “Scripts and Functions”

Who is online

Users browsing this forum: Xtra and 19 guests