duckling78 Posted February 25, 2012 Share Posted February 25, 2012 I found the following games benefit significantly if you change their process priority to "high":Global AgendaLeague of LegendsTeam Fortress 2CoD Black OpsBrawl BustersGotham City ImitatorsTribes AscendI 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).expandcollapse popup#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 EndFuncTo set the active process to normal: Ctrl + NumPadSubTo 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 More sharing options...
Moderators Melba23 Posted February 25, 2012 Moderators Share Posted February 25, 2012 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 VenusProject2 1 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
duckling78 Posted February 25, 2012 Author Share Posted February 25, 2012 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 BitGlobal Agenda performance:Normal priority: 15-40 FPSHigh priority: 45-80 FPSThis 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 More sharing options...
Moderators Melba23 Posted February 25, 2012 Moderators Share Posted February 25, 2012 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 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
NatePetty Posted December 23, 2012 Share Posted December 23, 2012 i play League of Legends and get high ping and low fps. how can i use ur script to set and save the Lol on high priority and how do i do it? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 23, 2012 Moderators Share Posted December 23, 2012 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. See you soon with a legitimate question, I hope. M23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Recommended Posts