SHARE
TWEET

Para's XTU Helper 1.05

lyzing Aug 9th, 2019 72 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #Region ;**** Directives created by AutoIt3Wrapper_GUI ****
  2. #AutoIt3Wrapper_Icon=XTU helper.ico
  3. #AutoIt3Wrapper_Outfile=Para's XTU Helper - ver. 1.05.exe
  4. #AutoIt3Wrapper_UseUpx=n
  5. #AutoIt3Wrapper_UseX64=n
  6. #AutoIt3Wrapper_Res_Fileversion=1.0.5.0
  7. #AutoIt3Wrapper_Res_LegalCopyright=Paraly
  8. #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
  9. Opt("TrayMenuMode", 1 + 2)
  10. TraySetToolTip("Para's XTU Helper")
  11.  
  12. Global $TRAY_Exit = TrayCreateItem("Exit")
  13. AdlibRegister("_TrayMSG", 100)
  14.  
  15. Global $XTU_Drive, $XTU_Path, $currentprofile = ""
  16.  
  17. If IsAdmin() = 0 Then
  18.     TrayTip("Para's XTU Helper","No Admin Permissions, can't adjust voltages and probably can't run addon programms that require admin privileges" &@CRLF& "it's recommend to set the XTU Helper as service with Admin privileges",3,2)
  19.     Sleep(3000)
  20. EndIf
  21.  
  22.  
  23. If FileExists("C:\Program Files (x86)\Intel\Intel(R) Extreme Tuning Utility\Client\XtuCLI.exe") Then
  24.     $XTU_Path = "C:\Program Files (x86)\Intel\Intel(R) Extreme Tuning Utility\Client"
  25.     $XTU_Drive = "C:"
  26. ElseIf IniRead(@ScriptDir & "\settings.ini","Main","XTUPath","") <> "" Then
  27.     $XTU_Path = StringRegExpReplace(IniRead(@ScriptDir & "\settings.ini","Main","XTUPath",""),'(?i)\\xtucli.exe','')
  28.     If StringRight($XTU_Path,1) = "\" Then
  29.         $XTU_Path = StringTrimRight($XTU_Path,1)
  30.     EndIf
  31.     $XTU_Drive = StringLeft($XTU_Path,2)
  32. Else
  33.     Local $LoadPath = FileOpenDialog("Select the xtucli.exe (old XTU version required)", @ProgramFilesDir, "xtucli.exe (xtucli.exe)", 1 + 2)
  34.     If $LoadPath <> "" Then
  35.         $XTU_Path = StringRegExpReplace($LoadPath,'(?i)\\xtucli.exe','')
  36.         $XTU_Drive = StringLeft($LoadPath,2)
  37.     EndIf
  38. EndIf
  39.  
  40. If FileExists($XTU_Path & "\xtucli.exe") = 0 Then
  41.     MsgBox(16,"ERROR","xtucli.exe not found, this file is only available in an old XTU version")
  42.     Exit
  43. EndIf
  44.  
  45.  
  46. If FileExists(@ScriptDir & "\settings.ini") = 0 Then
  47.     $f = FileOpen(@ScriptDir & "\settings.ini",10)
  48.     FileClose($f)
  49.  
  50.     IniWrite(@ScriptDir & "\settings.ini", "Main", "Total",1)
  51.     IniWrite(@ScriptDir & "\settings.ini", "Main", "Notifications",1)
  52.     IniWrite(@ScriptDir & "\settings.ini", "Main", "XTUPath","")
  53.     IniWrite(@ScriptDir & "\settings.ini", "Main", "OBDefaultWattage",7)
  54.     IniWrite(@ScriptDir & "\settings.ini", "Main", "OBDefaultShortWattage",12)
  55.     IniWrite(@ScriptDir & "\settings.ini", "Main", "OBDefaultCPUVoltageOffset",0)
  56.     IniWrite(@ScriptDir & "\settings.ini", "Main", "OBDefaultGPUVoltageOffset",0)
  57.     IniWrite(@ScriptDir & "\settings.ini", "Main", "OCDefaultWattage",7)
  58.     IniWrite(@ScriptDir & "\settings.ini", "Main", "OCDefaultShortWattage",12)
  59.     IniWrite(@ScriptDir & "\settings.ini", "Main", "OCDefaultCPUVoltageOffset",0)
  60.     IniWrite(@ScriptDir & "\settings.ini", "Main", "OCDefaultGPUVoltageOffset",0)
  61.  
  62.     IniWrite(@ScriptDir & "\settings.ini", "Executable", "1","Citra-qt.exe")
  63.  
  64.     IniWrite(@ScriptDir & "\settings.ini", "OBWattage", "1","9.exe")
  65.  
  66.     IniWrite(@ScriptDir & "\settings.ini", "OBShortWattage", "1","15.exe")
  67.  
  68.     IniWrite(@ScriptDir & "\settings.ini", "OBDefaultCPUVoltageOffset", "1","-50")
  69.  
  70.     IniWrite(@ScriptDir & "\settings.ini", "OBDefaultGPUVoltageOffset", "1","-55")
  71.  
  72.     IniWrite(@ScriptDir & "\settings.ini", "OCDefaultWattage", "1","10")
  73.  
  74.     IniWrite(@ScriptDir & "\settings.ini", "OCDefaultShortWattage", "1","15")
  75.  
  76.     IniWrite(@ScriptDir & "\settings.ini", "OCDefaultCPUVoltageOffset", "1","-50")
  77.  
  78.     IniWrite(@ScriptDir & "\settings.ini", "OCDefaultGPUVoltageOffset", "1","-55")
  79.  
  80.     IniWrite(@ScriptDir & "\settings.ini", "RunAddon", "1","C:\Users\Paral\Documents\XPadder\Xpadder.exe CitraProfile /m")
  81.  
  82.     IniWrite(@ScriptDir & "\settings.ini", "DelayedKeyStroke", "1","{F5},5000")
  83. EndIf
  84.  
  85.  
  86. $Informations_Total = IniRead(@ScriptDir & "\settings.ini","Main","Total",1)
  87. $Informations_Notifications = IniRead(@ScriptDir & "\settings.ini","Main","Notifications",1)
  88.  
  89. $Informations_OBDefaultWattage = IniRead(@ScriptDir & "\settings.ini","Main","OBDefaultWattage",7)
  90. $Informations_OBShortWattage = IniRead(@ScriptDir & "\settings.ini","Main","OBDefaultShortWattage",15)
  91. $Informations_OBCPUVoltageOffset = IniRead(@ScriptDir & "\settings.ini","Main","OBDefaultCPUVoltageOffset",0)
  92. $Informations_OBGPUVoltageOffset = IniRead(@ScriptDir & "\settings.ini","Main","OBDefaultGPUVoltageOffset",0)
  93.  
  94. $Informations_OCDefaultWattage = IniRead(@ScriptDir & "\settings.ini","Main","OCDefaultWattage",7)
  95. $Informations_OCShortWattage = IniRead(@ScriptDir & "\settings.ini","Main","OCDefaultShortWattage",15)
  96. $Informations_OCCPUVoltageOffset = IniRead(@ScriptDir & "\settings.ini","Main","OCDefaultCPUVoltageOffset",0)
  97. $Informations_OCGPUVoltageOffset = IniRead(@ScriptDir & "\settings.ini","Main","OCDefaultGPUVoltageOffset",0)
  98. Dim $Informations[$Informations_Total][11]
  99.  
  100.  
  101. For $i = 0 To $Informations_Total-1
  102.    $Informations[$i][0] = IniRead(@ScriptDir & "\settings.ini","Executable",$i+1,"")
  103.    $Informations[$i][1] = IniRead(@ScriptDir & "\settings.ini","OBWattage",$i+1,"")
  104.    $Informations[$i][2] = IniRead(@ScriptDir & "\settings.ini","OBShortWattage",$i+1,"")
  105.    $Informations[$i][3] = IniRead(@ScriptDir & "\settings.ini","OBDefaultCPUVoltageOffset",$i+1,"")
  106.    $Informations[$i][4] = IniRead(@ScriptDir & "\settings.ini","OBDefaultGPUVoltageOffset",$i+1,"")
  107.    $Informations[$i][5] = IniRead(@ScriptDir & "\settings.ini","OCDefaultWattage",$i+1,"")
  108.    $Informations[$i][6] = IniRead(@ScriptDir & "\settings.ini","OCDefaultShortWattage",$i+1,"")
  109.    $Informations[$i][7] = IniRead(@ScriptDir & "\settings.ini","OCDefaultCPUVoltageOffset",$i+1,"")
  110.    $Informations[$i][8] = IniRead(@ScriptDir & "\settings.ini","OCDefaultGPUVoltageOffset",$i+1,"")
  111.    $Informations[$i][9] = IniRead(@ScriptDir & "\settings.ini","RunAddon",$i+1,"")
  112.    $Informations[$i][10] = IniRead(@ScriptDir & "\settings.ini","DelayedKeyStroke",$i+1,"")
  113. Next
  114.  
  115.  
  116. $BatteryStatus = _ComputerGetBattery()
  117. If $BatteryStatus = False Then
  118.    _ApplySettings($Informations_OBDefaultWattage,$Informations_OBShortWattage,$Informations_OBCPUVoltageOffset,$Informations_OBGPUVoltageOffset)
  119.    $currentprofile = False
  120. ElseIf $BatteryStatus = True Then
  121.    _ApplySettings($Informations_OCDefaultWattage,$Informations_OCShortWattage,$Informations_OCCPUVoltageOffset,$Informations_OCGPUVoltageOffset)
  122.    $currentprofile = True
  123. EndIf
  124.  
  125. While 1
  126.     $ProcessArray = ProcessList()
  127.     For $i2 = 1 To $ProcessArray[0][0]
  128.         For $i = 0 To $Informations_Total-1
  129.             If $ProcessArray[$i2][0] = $Informations[$i][0] Then
  130.                 $EXEPID = $ProcessArray[$i2][1]
  131.                 If $Informations[$i][9] <> "" Then
  132.                     $AddonPID = Run($Informations[$i][9])
  133.                 EndIf
  134.                 If $Informations[$i][10] <> "" Then
  135.                    $DelayedKeyStroke_splitted = StringSplit($Informations[$i][10],",",1)
  136.                    AdlibRegister("_KeyStroke",$DelayedKeyStroke_splitted[1])
  137.                 EndIf
  138.                 $BatteryStatus = _ComputerGetBattery()
  139.                 If $BatteryStatus = False Then
  140.                     _ApplySettings($Informations[$i][1],$Informations[$i][2],$Informations[$i][3],$Informations[$i][4])
  141.                     $currentprofile = False
  142.                 ElseIf $BatteryStatus = True Then
  143.                     _ApplySettings($Informations[$i][5],$Informations[$i][6],$Informations[$i][7],$Informations[$i][8])
  144.                     $currentprofile = True
  145.                 EndIf
  146.                 While ProcessExists($EXEPID) > 0
  147.                     Sleep(3000)
  148.                     $BatteryStatus = _ComputerGetBattery()
  149.                     If $currentprofile <> $BatteryStatus Then
  150.                         If $BatteryStatus = False Then
  151.                             _ApplySettings($Informations[$i][1],$Informations[$i][2],$Informations[$i][3],$Informations[$i][4])
  152.                             $currentprofile = False
  153.                         ElseIf $BatteryStatus = True Then
  154.                             _ApplySettings($Informations[$i][5],$Informations[$i][6],$Informations[$i][7],$Informations[$i][8])
  155.                             $currentprofile = True
  156.                         EndIf
  157.                     EndIf
  158.                 WEnd
  159.                 If $Informations[$i][9] <> "" Then
  160.                     ProcessClose($AddonPID)
  161.                 EndIf
  162.                 $BatteryStatus = _ComputerGetBattery()
  163.                 If $BatteryStatus = False Then
  164.                     _ApplySettings($Informations_OBDefaultWattage,$Informations_OBShortWattage,$Informations_OBCPUVoltageOffset,$Informations_OBGPUVoltageOffset)
  165.                     $currentprofile = False
  166.                 ElseIf $BatteryStatus = True Then
  167.                     _ApplySettings($Informations_OCDefaultWattage,$Informations_OCShortWattage,$Informations_OCCPUVoltageOffset,$Informations_OCGPUVoltageOffset)
  168.                     $currentprofile = True
  169.                 EndIf
  170.             EndIf
  171.         Next
  172.     Next
  173.    $BatteryStatus = _ComputerGetBattery()
  174.    If $currentprofile <> $BatteryStatus Then
  175.        If $BatteryStatus = False Then
  176.            _ApplySettings($Informations_OBDefaultWattage,$Informations_OBShortWattage,$Informations_OBCPUVoltageOffset,$Informations_OBGPUVoltageOffset)
  177.            $currentprofile = False
  178.        ElseIf $BatteryStatus = True Then
  179.            _ApplySettings($Informations_OCDefaultWattage,$Informations_OCShortWattage,$Informations_OCCPUVoltageOffset,$Informations_OCGPUVoltageOffset)
  180.            $currentprofile = True
  181.        EndIf
  182.    EndIf
  183.    Sleep(3000)
  184. WEnd
  185.  
  186.  
  187.  
  188. Func _ApplySettings($wattage, $shortwattage, $cpuoffset, $gpuoffset)
  189.    If $wattage > 1 And $wattage < 16 And $shortwattage > 1 And $shortwattage < 16 And $cpuoffset <= 0 And $cpuoffset > -120 And $gpuoffset <= 0 And $gpuoffset > -120 Then
  190.        $CMD_PID = Run(@ComSpec & ' /c NET STOP XTU3SERVICE',"",@SW_HIDE)
  191.        While ProcessExists($CMD_PID) > 0
  192.            Sleep(500)
  193.        WEnd
  194.        $CMD_PID = Run(@ComSpec & ' /c NET START XTU3SERVICE && ' & $XTU_Drive & ' && cd "' & $XTU_Path & '" && xtucli.exe -t -id 34 -v 0 && xtucli.exe -t -id 100 -v 0 && xtucli.exe -t -id 48 -v ' & $wattage & ' && xtucli.exe -t -id 47 -v ' & $shortwattage & ' && xtucli.exe -t -id 34 -v ' & $cpuoffset & ' && xtucli.exe -t -id 100 -v ' & $gpuoffset & ' && TIMEOUT 2 && xtucli.exe -i tuning xml && NET STOP XTU3SERVICE',"",@SW_HIDE)
  195.        While ProcessExists($CMD_PID) > 0
  196.            Sleep(500)
  197.        WEnd
  198.        If $Informations_Notifications = 1 Then
  199.            TrayTip("Para's XTU Helper", "Power Max: " & $wattage & "w" & @CRLF & "Short Power Max: " & $shortwattage & "w" & @CRLF & "CPU Voltage Offset: " & $cpuoffset & @CRLF & "GPU Voltage Offset: " & $gpuoffset,3,1)
  200.        EndIf
  201.        Return True
  202.    Else
  203.        Return False
  204.    EndIf
  205. EndFunc
  206.  
  207.  
  208. Func _TrayMSG()
  209.    Local $tmsg = TrayGetMsg()
  210.    Select
  211.        Case $tmsg = $TRAY_Exit
  212.            Exit
  213.    EndSelect
  214. EndFunc
  215.  
  216.  
  217. Func _KeyStroke()
  218.  
  219. Send($DelayedKeyStroke_splitted[2])
  220. AdlibUnRegister("_KeyStroke")
  221.  
  222. EndFunc
  223.  
  224.  
  225. Func _ComputerGetBattery(); Function Author Jarvis J. Stubblefield (JSThePatriot) http://www.vortexrevolutions.com/
  226.    Local $colItems, $objWMIService, $objItem
  227.    Dim $aBatteryInfo[1][31], $ti = 1
  228.  
  229.    $objWMIService = ObjGet("winmgmts:\\" & @ComputerName & "\root\CIMV2")
  230.    $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_Battery", "WQL", 0x10 + 0x20)
  231.  
  232.    If IsObj($colItems) Then
  233.        For $objItem In $colItems
  234.            ReDim $aBatteryInfo[UBound($aBatteryInfo) + 1][31]
  235.            $aBatteryInfo[$ti][0]   = $objItem.Name
  236.            $aBatteryInfo[$ti][1]   = $objItem.Availability
  237.            $aBatteryInfo[$ti][2]   = $objItem.BatteryRechargeTime
  238.            $aBatteryInfo[$ti][3]   = $objItem.BatteryStatus
  239.            $aBatteryInfo[$ti][4]   = $objItem.Description
  240.            $aBatteryInfo[$ti][5]   = $objItem.Chemistry
  241.            $aBatteryInfo[$ti][6]   = $objItem.ConfigManagerErrorCode
  242.            $aBatteryInfo[$ti][7]   = $objItem.ConfigManagerUserConfig
  243.            $aBatteryInfo[$ti][8]   = $objItem.CreationClassName
  244.            $aBatteryInfo[$ti][9]   = $objItem.DesignCapacity
  245.            $aBatteryInfo[$ti][10]  = $objItem.DesignVoltage
  246.            $aBatteryInfo[$ti][11]  = $objItem.DeviceID
  247.            $aBatteryInfo[$ti][12]  = $objItem.ErrorCleared
  248.            $aBatteryInfo[$ti][13]  = $objItem.ErrorDescription
  249.            $aBatteryInfo[$ti][14]  = $objItem.EstimatedChargeRemaining
  250.            $aBatteryInfo[$ti][15]  = $objItem.EstimatedRunTime
  251.            $aBatteryInfo[$ti][16]  = $objItem.ExpectedBatteryLife
  252.            $aBatteryInfo[$ti][17]  = $objItem.ExpectedLife
  253.            $aBatteryInfo[$ti][18]  = $objItem.FullChargeCapacity
  254.            $aBatteryInfo[$ti][19]  = $objItem.LastErrorCode
  255.            $aBatteryInfo[$ti][20]  = $objItem.MaxRechargeTime
  256.            $aBatteryInfo[$ti][21]  = $objItem.PNPDeviceID
  257.            $aBatteryInfo[$ti][22]  = $objItem.PowerManagementCapabilities(0)
  258.            $aBatteryInfo[$ti][23]  = $objItem.PowerManagementSupported
  259.            $aBatteryInfo[$ti][24]  = $objItem.SmartBatteryVersion
  260.            $aBatteryInfo[$ti][25]  = $objItem.Status
  261.            $aBatteryInfo[$ti][26]  = $objItem.StatusInfo
  262.            $aBatteryInfo[$ti][27]  = $objItem.SystemCreationClassName
  263.            $aBatteryInfo[$ti][28]  = $objItem.SystemName
  264.            $aBatteryInfo[$ti][29]  = $objItem.TimeOnBattery
  265.            $aBatteryInfo[$ti][30]  = $objItem.TimeToFullCharge
  266.            $ti += 1
  267.        Next
  268.        $aBatteryInfo[0][0] = UBound($aBatteryInfo) - 1
  269.        If $aBatteryInfo[1][3] = 1 Then
  270.            Return False
  271.        ElseIf $aBatteryInfo[1][3] = 2 Then
  272.            Return True
  273.        EndIf
  274.  
  275.        If $aBatteryInfo[0][3] = 1 Then
  276.            Return False
  277.        ElseIf $aBatteryInfo[0][3] = 2 Then
  278.            Return True
  279.        EndIf
  280.    EndIf
  281. EndFunc
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top