Jump to content
Sign in to follow this  
Hyflex

Set Processor Affinity & Priority (Low)

Recommended Posts

Hyflex

I've tried getting it to work but it's not working, I did find a tool months ago in the script section what allowed me to easily control the affinity and priority but I can no longer find it.

I want it really easy to change them from low to high.

#include <WinAPI.au3>
$HoProcess = ProcessList("ho.exe")
For $i = 1 To $HoProcess[0][0]
    ProcessSetPriority ($HoProcess[$i][1], 0 )
    _WinAPI_SetProcessAffinityMask($HoProcess[$i][1], 0x01)
Next

Please help

- XG

Share this post


Link to post
Share on other sites
BrewManNH

ProcessSetPriority goes from Low (0) to Realtime (5), you're using it backwards.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites
Hyflex

ProcessSetPriority goes from Low (0) to Realtime (5), you're using it backwards.

I want the macro to set them as low as possible at first, then I will make another or a switch to turn them to high...

Share this post


Link to post
Share on other sites
BrewManNH

You should check the return values of the ProcessList, the ProcessSetAffinity and the _WinAPI_SetProcessAffinityMask to make sure that they return as completing successfully. Somewhere in that chain of events you're attempting one or all of them must be failing.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites
Hyflex

You should check the return values of the ProcessList, the ProcessSetAffinity and the _WinAPI_SetProcessAffinityMask to make sure that they return as completing successfully. Somewhere in that chain of events you're attempting one or all of them must be failing.

The ProcessList part works fine, the set priority works fine but the Affinity doesn't work as I can't find out how to use it correctly.

Share this post


Link to post
Share on other sites
JohnOne

The ProcessList part works fine, the set priority works fine but the Affinity doesn't work as I can't find out how to use it correctly.

Well for a start, the helpfilr says the first param is a process handle not a PID.


AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites
BrewManNH

Good catch JohnOne,missed that one because the problem wasn't clear from the OP.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites
Hyflex

I'm unable to get any further, I've tried to try and use a bunch of functions...

I have 8 processes, all with same name, I need to turn them all to Priority Low and Affinity to core 1

I've tried using WinGetTitle, _WinGetByPID, WinGetHandle and a few others but I can't do it ;)

Share this post


Link to post
Share on other sites
BrewManNH

WinList perhaps? Seeing as how you got the ProcessList using the program name, you should be able to list all of the windows with the WinList command, as long as the windows titles are all the same. Once you have the handles, go through them the same way you did with the ProcessSetPriority.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×