SHARE
TWEET

Para's XTU Helper 1.06

lyzing Aug 9th, 2019 89 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.06.exe
  4. #AutoIt3Wrapper_UseUpx=n
  5. #AutoIt3Wrapper_UseX64=n
  6. #AutoIt3Wrapper_Res_Fileversion=1.0.6.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.     FileWrite($f,';OB means "On Battery"' & @CRLF & ';OC means "On Charge"' & @CRLF & ';under RunAddon you can run additional programs to your game like xpadder' & @CRLF & ';under KeyStroke you can send a certain keystroke after a certain delay in ms' & @CRLF & ";Total needs the amount of games you've saved here" & @CRLF & ";You need an old version of XTU, here's a download to it: https://drive.google.com/file/d/19pcfT_GUMaUy68opuwn0iQMUPWsW_T9d/view?usp=sharing" & @CRLF & @CRLF)
  49.     FileClose($f)
  50.  
  51.     IniWrite(@ScriptDir & "\settings.ini", "Main", "Total",1)
  52.     IniWrite(@ScriptDir & "\settings.ini", "Main", "Notifications",1)
  53.     IniWrite(@ScriptDir & "\settings.ini", "Main", "XTUPath","")
  54.     IniWrite(@ScriptDir & "\settings.ini", "Main", "OBDefaultWattage",7)
  55.     IniWrite(@ScriptDir & "\settings.ini", "Main", "OBDefaultShortWattage",12)
  56.     IniWrite(@ScriptDir & "\settings.ini", "Main", "OBDefaultCPUVoltageOffset",0)
  57.     IniWrite(@ScriptDir & "\settings.ini", "Main", "OBDefaultGPUVoltageOffset",0)
  58.     IniWrite(@ScriptDir & "\settings.ini", "Main", "OCDefaultWattage",7)
  59.     IniWrite(@ScriptDir & "\settings.ini", "Main", "OCDefaultShortWattage",12)
  60.     IniWrite(@ScriptDir & "\settings.ini", "Main", "OCDefaultCPUVoltageOffset",0)
  61.     IniWrite(@ScriptDir & "\settings.ini", "Main", "OCDefaultGPUVoltageOffset",0)
  62.  
  63.     IniWrite(@ScriptDir & "\settings.ini", "Executable", "1","Citra-qt.exe")
  64.  
  65.     IniWrite(@ScriptDir & "\settings.ini", "OBWattage", "1","9.exe")
  66.  
  67.     IniWrite(@ScriptDir & "\settings.ini", "OBShortWattage", "1","15.exe")
  68.  
  69.     IniWrite(@ScriptDir & "\settings.ini", "OBDefaultCPUVoltageOffset", "1","-50")
  70.  
  71.     IniWrite(@ScriptDir & "\settings.ini", "OBDefaultGPUVoltageOffset", "1","-55")
  72.  
  73.     IniWrite(@ScriptDir & "\settings.ini", "OCDefaultWattage", "1","10")
  74.  
  75.     IniWrite(@ScriptDir & "\settings.ini", "OCDefaultShortWattage", "1","15")
  76.  
  77.     IniWrite(@ScriptDir & "\settings.ini", "OCDefaultCPUVoltageOffset", "1","-50")
  78.  
  79.     IniWrite(@ScriptDir & "\settings.ini", "OCDefaultGPUVoltageOffset", "1","-55")
  80.  
  81.     IniWrite(@ScriptDir & "\settings.ini", "RunAddon", "1","C:\Users\Paral\Documents\XPadder\Xpadder.exe CitraProfile /m")
  82.  
  83.     IniWrite(@ScriptDir & "\settings.ini", "DelayedKeyStroke", "1","{F5},5000")
  84. EndIf
  85.  
  86.  
  87. $Informations_Total = IniRead(@ScriptDir & "\settings.ini","Main","Total",1)
  88. $Informations_Notifications = IniRead(@ScriptDir & "\settings.ini","Main","Notifications",1)
  89.  
  90. $Informations_OBDefaultWattage = IniRead(@ScriptDir & "\settings.ini","Main","OBDefaultWattage",7)
  91. $Informations_OBShortWattage = IniRead(@ScriptDir & "\settings.ini","Main","OBDefaultShortWattage",15)
  92. $Informations_OBCPUVoltageOffset = IniRead(@ScriptDir & "\settings.ini","Main","OBDefaultCPUVoltageOffset",0)
  93. $Informations_OBGPUVoltageOffset = IniRead(@ScriptDir & "\settings.ini","Main","OBDefaultGPUVoltageOffset",0)
  94.  
  95. $Informations_OCDefaultWattage = IniRead(@ScriptDir & "\settings.ini","Main","OCDefaultWattage",7)
  96. $Informations_OCShortWattage = IniRead(@ScriptDir & "\settings.ini","Main","OCDefaultShortWattage",15)
  97. $Informations_OCCPUVoltageOffset = IniRead(@ScriptDir & "\settings.ini","Main","OCDefaultCPUVoltageOffset",0)
  98. $Informations_OCGPUVoltageOffset = IniRead(@ScriptDir & "\settings.ini","Main","OCDefaultGPUVoltageOffset",0)
  99. Dim $Informations[$Informations_Total][11]
  100.  
  101.  
  102. For $i = 0 To $Informations_Total-1
  103.     $Informations[$i][0] = IniRead(@ScriptDir & "\settings.ini","Executable",$i+1,"")
  104.     $Informations[$i][1] = IniRead(@ScriptDir & "\settings.ini","OBWattage",$i+1,"")
  105.     $Informations[$i][2] = IniRead(@ScriptDir & "\settings.ini","OBShortWattage",$i+1,"")
  106.     $Informations[$i][3] = IniRead(@ScriptDir & "\settings.ini","OBDefaultCPUVoltageOffset",$i+1,"")
  107.     $Informations[$i][4] = IniRead(@ScriptDir & "\settings.ini","OBDefaultGPUVoltageOffset",$i+1,"")
  108.     $Informations[$i][5] = IniRead(@ScriptDir & "\settings.ini","OCDefaultWattage",$i+1,"")
  109.     $Informations[$i][6] = IniRead(@ScriptDir & "\settings.ini","OCDefaultShortWattage",$i+1,"")
  110.     $Informations[$i][7] = IniRead(@ScriptDir & "\settings.ini","OCDefaultCPUVoltageOffset",$i+1,"")
  111.     $Informations[$i][8] = IniRead(@ScriptDir & "\settings.ini","OCDefaultGPUVoltageOffset",$i+1,"")
  112.     $Informations[$i][9] = IniRead(@ScriptDir & "\settings.ini","RunAddon",$i+1,"")
  113.     $Informations[$i][10] = IniRead(@ScriptDir & "\settings.ini","DelayedKeyStroke",$i+1,"")
  114. Next
  115.  
  116.  
  117. $BatteryStatus = _ComputerGetBattery()
  118. If $BatteryStatus = False Then
  119.     _ApplySettings($Informations_OBDefaultWattage,$Informations_OBShortWattage,$Informations_OBCPUVoltageOffset,$Informations_OBGPUVoltageOffset)
  120.     $currentprofile = False
  121. ElseIf $BatteryStatus = True Then
  122.     _ApplySettings($Informations_OCDefaultWattage,$Informations_OCShortWattage,$Informations_OCCPUVoltageOffset,$Informations_OCGPUVoltageOffset)
  123.     $currentprofile = True
  124. EndIf
  125.  
  126. While 1
  127.     $ProcessArray = ProcessList()
  128.     For $i2 = 1 To $ProcessArray[0][0]
  129.         For $i = 0 To $Informations_Total-1
  130.             If $ProcessArray[$i2][0] = $Informations[$i][0] Then
  131.                 $EXEPID = $ProcessArray[$i2][1]
  132.                 If $Informations[$i][9] <> "" Then
  133.                     $AddonPID = Run($Informations[$i][9])
  134.                 EndIf
  135.                 If $Informations[$i][10] <> "" Then
  136.                    $DelayedKeyStroke_splitted = StringSplit($Informations[$i][10],",",1)
  137.                    AdlibRegister("_KeyStroke",$DelayedKeyStroke_splitted[1])
  138.                 EndIf
  139.                 $BatteryStatus = _ComputerGetBattery()
  140.                 If $BatteryStatus = False Then
  141.                     _ApplySettings($Informations[$i][1],$Informations[$i][2],$Informations[$i][3],$Informations[$i][4])
  142.                     $currentprofile = False
  143.                 ElseIf $BatteryStatus = True Then
  144.                     _ApplySettings($Informations[$i][5],$Informations[$i][6],$Informations[$i][7],$Informations[$i][8])
  145.                     $currentprofile = True
  146.                 EndIf
  147.                 While ProcessExists($EXEPID) > 0
  148.                     Sleep(3000)
  149.                     $BatteryStatus = _ComputerGetBattery()
  150.                     If $currentprofile <> $BatteryStatus Then
  151.                         If $BatteryStatus = False Then
  152.                             _ApplySettings($Informations[$i][1],$Informations[$i][2],$Informations[$i][3],$Informations[$i][4])
  153.                             $currentprofile = False
  154.                         ElseIf $BatteryStatus = True Then
  155.                             _ApplySettings($Informations[$i][5],$Informations[$i][6],$Informations[$i][7],$Informations[$i][8])
  156.                             $currentprofile = True
  157.                         EndIf
  158.                     EndIf
  159.                 WEnd
  160.                 If $Informations[$i][9] <> "" Then
  161.                     ProcessClose($AddonPID)
  162.                 EndIf
  163.                 $BatteryStatus = _ComputerGetBattery()
  164.                 If $BatteryStatus = False Then
  165.                     _ApplySettings($Informations_OBDefaultWattage,$Informations_OBShortWattage,$Informations_OBCPUVoltageOffset,$Informations_OBGPUVoltageOffset)
  166.                     $currentprofile = False
  167.                 ElseIf $BatteryStatus = True Then
  168.                     _ApplySettings($Informations_OCDefaultWattage,$Informations_OCShortWattage,$Informations_OCCPUVoltageOffset,$Informations_OCGPUVoltageOffset)
  169.                     $currentprofile = True
  170.                 EndIf
  171.             EndIf
  172.         Next
  173.     Next
  174.     $BatteryStatus = _ComputerGetBattery()
  175.     If $currentprofile <> $BatteryStatus Then
  176.         If $BatteryStatus = False Then
  177.             _ApplySettings($Informations_OBDefaultWattage,$Informations_OBShortWattage,$Informations_OBCPUVoltageOffset,$Informations_OBGPUVoltageOffset)
  178.             $currentprofile = False
  179.         ElseIf $BatteryStatus = True Then
  180.             _ApplySettings($Informations_OCDefaultWattage,$Informations_OCShortWattage,$Informations_OCCPUVoltageOffset,$Informations_OCGPUVoltageOffset)
  181.             $currentprofile = True
  182.         EndIf
  183.     EndIf
  184.     Sleep(3000)
  185. WEnd
  186.  
  187.  
  188.  
  189. Func _ApplySettings($wattage, $shortwattage, $cpuoffset, $gpuoffset)
  190.     If $wattage > 1 And $wattage < 18 And $shortwattage > 1 And $shortwattage < 18 And $cpuoffset <= 0 And $cpuoffset > -120 And $gpuoffset <= 0 And $gpuoffset > -120 Then
  191.         $CMD_PID = Run(@ComSpec & ' /c NET STOP XTU3SERVICE',"",@SW_HIDE)
  192.         While ProcessExists($CMD_PID) > 0
  193.             Sleep(500)
  194.         WEnd
  195.         $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)
  196.         While ProcessExists($CMD_PID) > 0
  197.             Sleep(500)
  198.         WEnd
  199.         If $Informations_Notifications = 1 Then
  200.             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)
  201.         EndIf
  202.         Return True
  203.     Else
  204.         Return False
  205.     EndIf
  206. EndFunc
  207.  
  208.  
  209. Func _TrayMSG()
  210.     Local $tmsg = TrayGetMsg()
  211.     Select
  212.         Case $tmsg = $TRAY_Exit
  213.             Exit
  214.     EndSelect
  215. EndFunc
  216.  
  217.  
  218. Func _KeyStroke()
  219.  
  220. Send($DelayedKeyStroke_splitted[2])
  221. AdlibUnRegister("_KeyStroke")
  222.  
  223. EndFunc
  224.  
  225.  
  226. Func _ComputerGetBattery(); Function Author Jarvis J. Stubblefield (JSThePatriot) http://www.vortexrevolutions.com/
  227.     Local $colItems, $objWMIService, $objItem
  228.     Dim $aBatteryInfo[1][31], $ti = 1
  229.  
  230.     $objWMIService = ObjGet("winmgmts:\\" & @ComputerName & "\root\CIMV2")
  231.     $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_Battery", "WQL", 0x10 + 0x20)
  232.  
  233.     If IsObj($colItems) Then
  234.         For $objItem In $colItems
  235.             ReDim $aBatteryInfo[UBound($aBatteryInfo) + 1][31]
  236.             $aBatteryInfo[$ti][0]   = $objItem.Name
  237.             $aBatteryInfo[$ti][1]   = $objItem.Availability
  238.             $aBatteryInfo[$ti][2]   = $objItem.BatteryRechargeTime
  239.             $aBatteryInfo[$ti][3]   = $objItem.BatteryStatus
  240.             $aBatteryInfo[$ti][4]   = $objItem.Description
  241.             $aBatteryInfo[$ti][5]   = $objItem.Chemistry
  242.             $aBatteryInfo[$ti][6]   = $objItem.ConfigManagerErrorCode
  243.             $aBatteryInfo[$ti][7]   = $objItem.ConfigManagerUserConfig
  244.             $aBatteryInfo[$ti][8]   = $objItem.CreationClassName
  245.             $aBatteryInfo[$ti][9]   = $objItem.DesignCapacity
  246.             $aBatteryInfo[$ti][10]  = $objItem.DesignVoltage
  247.             $aBatteryInfo[$ti][11]  = $objItem.DeviceID
  248.             $aBatteryInfo[$ti][12]  = $objItem.ErrorCleared
  249.             $aBatteryInfo[$ti][13]  = $objItem.ErrorDescription
  250.             $aBatteryInfo[$ti][14]  = $objItem.EstimatedChargeRemaining
  251.             $aBatteryInfo[$ti][15]  = $objItem.EstimatedRunTime
  252.             $aBatteryInfo[$ti][16]  = $objItem.ExpectedBatteryLife
  253.             $aBatteryInfo[$ti][17]  = $objItem.ExpectedLife
  254.             $aBatteryInfo[$ti][18]  = $objItem.FullChargeCapacity
  255.             $aBatteryInfo[$ti][19]  = $objItem.LastErrorCode
  256.             $aBatteryInfo[$ti][20]  = $objItem.MaxRechargeTime
  257.             $aBatteryInfo[$ti][21]  = $objItem.PNPDeviceID
  258.             $aBatteryInfo[$ti][22]  = $objItem.PowerManagementCapabilities(0)
  259.             $aBatteryInfo[$ti][23]  = $objItem.PowerManagementSupported
  260.             $aBatteryInfo[$ti][24]  = $objItem.SmartBatteryVersion
  261.             $aBatteryInfo[$ti][25]  = $objItem.Status
  262.             $aBatteryInfo[$ti][26]  = $objItem.StatusInfo
  263.             $aBatteryInfo[$ti][27]  = $objItem.SystemCreationClassName
  264.             $aBatteryInfo[$ti][28]  = $objItem.SystemName
  265.             $aBatteryInfo[$ti][29]  = $objItem.TimeOnBattery
  266.             $aBatteryInfo[$ti][30]  = $objItem.TimeToFullCharge
  267.             $ti += 1
  268.         Next
  269.         $aBatteryInfo[0][0] = UBound($aBatteryInfo) - 1
  270.         If $aBatteryInfo[1][3] = 1 Then
  271.             Return False
  272.         ElseIf $aBatteryInfo[1][3] = 2 Then
  273.             Return True
  274.         EndIf
  275.  
  276.         If $aBatteryInfo[0][3] = 1 Then
  277.             Return False
  278.         ElseIf $aBatteryInfo[0][3] = 2 Then
  279.             Return True
  280.         EndIf
  281.     EndIf
  282. 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