Jump to content

Speed up any game! (process set priority = high)


duckling78
 Share

Recommended Posts

I found the following games benefit significantly if you change their process priority to "high":

  • Global Agenda
  • League of Legends
  • Team Fortress 2
  • CoD Black Ops
  • Brawl Busters
  • Gotham City Imitators
  • Tribes Ascend
I got tired of opening Task Manager, going to the Processes tab, looking for the executable, right clicking on it, selection Priority and setting it to high every time I started a game, so I made this script to set the currently running process to High Priority with one key press (by default it is set to Ctrl + NumPadAdd).

#cs ----------------------------------------------------------------------------

AutoIt Version: 3.3.6.1
Author:      micsun

Script Function:
  Set the current running application to be high priority.

Default keys:
  Ctrl + NumPadAdd: Sets the current process to "high" priority level
  Ctrl + NumPadSub: Sets the current process to "normal" priority level
  Ctrl + Shift + Alt + Esc: Exit the script

#ce ----------------------------------------------------------------------------

#include <Process.au3>
#include <WinAPI.au3>
#include <Misc.au3>

If (_Singleton("AutoPriority", 1) == 0) Then
MsgBox(0, @ScriptName, "Another instance of this script is currently running.")
Exit
EndIf

Const $CTRLALTSHIFT_ESC = "+^!{Esc}"
Const $CTRL_NUMPADADD = "^{NumPadAdd}"
Const $CTRL_NUMPADSUB = "^{NumPadSub}"

Const $PRIORITY_IDLE = 0
Const $PRIORITY_BELOW_NORMAL = 1
Const $PRIORITY_NORMAL = 2
Const $PRIORITY_ABOVE_NORMAL = 3
Const $PRIORITY_HIGH = 4
Const $PRIORITY_REALTIME = 5

Const $TRAY_AUTO_PAUSE_DISABLED = 0
Const $TRAY_AUTO_PAUSE_ENABLED = 1

Const $TRAY_MENU_MODE_DEFAULT = 0
Const $TRAY_MENU_MODE_NO_DEFAULT = 1

Const $TRAY_ON_EVENT_MODE_DISABLE = 0
Const $TRAY_ON_EVENT_MODE_ENABLE = 1

init()

While True
Sleep(1000)
WEnd

Func init()
initTray()
initHotkeys()
EndFunc

Func initTray()
Opt("TrayAutoPause", $TRAY_AUTO_PAUSE_DISABLED)
Opt("TrayMenuMode", $TRAY_MENU_MODE_NO_DEFAULT)
Opt("TrayOnEventMode", $TRAY_ON_EVENT_MODE_ENABLE)
TrayItemSetOnEvent(TrayCreateItem("Exit " & StringTrimRight(@ScriptName, 4)), "onExitClicked")
EndFunc

Func onExitClicked()
Exit
EndFunc

Func initHotkeys()
HotKeySet($CTRLALTSHIFT_ESC, "exitScript")
HotKeySet($CTRL_NUMPADADD, "setPriorityHigh")
HotKeySet($CTRL_NUMPADSUB, "setPriorityMedium")
EndFunc

Func setPriorityHigh()
ConsoleWrite("+" & @CRLF)
setActiveWindowPriority($PRIORITY_HIGH)
EndFunc

Func setPriorityMedium()
ConsoleWrite("-" & @CRLF)
setActiveWindowPriority($PRIORITY_NORMAL)
EndFunc

Func setActiveWindowPriority($priority_type)
$windowList = WinList()

For $i = 1 to $windowList[0][0]
  $winName = $windowList[$i][0]

  If (isActive($winName)) Then
   ProcessSetPriority(WinGetProcess($winName), $priority_type)
   Return
  EndIf
Next
EndFunc

Func isActive($win_name)
Return (($win_name <> "") And WinActive($win_name)
EndFunc

Func exitScript()
Exit
EndFunc

To set the active process to normal: Ctrl + NumPadSub

To quit the script, just right click on the tray icon and select "Exit" or press Ctrl+Alt+Shift+Esc.

Link to comment
Share on other sites

  • Moderators

duckling78,

Without wishing to criticize your script, I would like to point you and anyone using it to this snippet from the Windows Dev Denter:

"Use HIGH_PRIORITY_CLASS with care. If a thread runs at the highest priority level for extended periods, other threads in the system will not get processor time. If several threads are set at high priority at the same time, the threads lose their effectiveness. The high-priority class should be reserved for threads that must respond to time-critical events. If your application performs one task that requires the high-priority class while the rest of its tasks are normal priority, use SetPriorityClass to raise the priority class of the application temporarily; then reduce it after the time-critical task has been completed. Another strategy is to create a high-priority process that has all of its threads blocked most of the time, awakening threads only when critical tasks are needed. The important point is that a high-priority thread should execute for a brief time, and only when it has time-critical work to perform."

Personally I only ever set apps that will run permanently to the ABOVE_NORMAL_PRIORITY_CLASS - and the improvement is already noticable. :)

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

 

Link to comment
Share on other sites

What you say is true, but for gamers that want their single threaded game (most games unfortunately) to run as fast as possible, the "high" priority type seems to work wonders. Just toggling it to normal using the provided hotkey before task switching away from the game should be fine. Most of the time I'm playing these games I'm *only* playing the games and don't want other things on the computer taking CPU time away from the game.

My computer: Core 2 Duo 3 Ghz, nVidia GTX 280, 4 GB, Vista 64 Bit

Global Agenda performance:

Normal priority: 15-40 FPS

High priority: 45-80 FPS

This makes no sense to me why I get such huge gains in frame rate, but I like it a lot :) I see very similar frame rate improvements in Gotham City Imposters but I haven't played that as long since it kind of just came out a couple of weeks ago.

I added some descriptive consts in case anyone wants to fool around with the other priority levels, but I've seen some great gains using the "high" setting. Don't use the "realtime" setting. I've never had any good results with that.

Link to comment
Share on other sites

  • Moderators

duckling78,

Understood, but as this script could be used on any active process (the reason it does not fall foul of the Forum Rules ;)) I felt it worth mentioning. :)

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

 

Link to comment
Share on other sites

  • 9 months later...
  • Moderators

NatePetty,

Welcome to the AutoIt forum. :)

If you look at the Forum Rules you will see that we do not support game automation scripts. The OP's script was allowed as it was sufficiently generic to be of interest outside gaming - albeit not without possible problems as I pointed out at the time. However your request is very game specific and so is not allowed. As a result I am now locking this thread. :naughty:

See you soon with a legitimate question, I hope. :)

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

 

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...