Windows 7 Forums

Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.


Windows 7: How to access "Processor Affinity" screen without Task Manager?

27 Jun 2013   #1
GbeTech

Win7 Pro SP1 64
 
 
How to access "Processor Affinity" screen without Task Manager?

Hey.

I'm trying to create a macro, through Auto HotKey, that will automatically set the processor affinity of some program.

It's problematic because the only way I know of, is to right click the process in Task Manager. The process's location changes each time, so I can't direct the macro to it. (I'm directing it by providing pixel coordinates, XY)

Is there a file, or static window - the processes window in Task Manager isn't static, it's constantly updating - that can give me access to the processor affinity window?


Thanks.


My System SpecsSystem Spec
.
27 Jun 2013   #2
sdadamo

Microsoft Windows 7 Ultimate 64-bit 7601 Multiprocessor Free Service Pack 1
 
 

Well uh this might help you - Run your games or applications on a single core to avoid crashes - Active+ Software

You could dig into that program's code and find something there.
My System SpecsSystem Spec
27 Jun 2013   #3
MilesAhead

Windows 7 32 bit
 
 

I don't remember it off hand, but I think there's a program launcher or command line that can set the affinity when the program is run. A search of softpedia shows this command line utility that seems close to what I'm remembering
ProcAff Free Download

For AHK you could do something in psudocode like
if process exists name
kill process,
run command line app that starts it with affinity

instead of doing it the macro way

( edit: looking at the app's options you can just change affinity instead of killing it etc.. )
My System SpecsSystem Spec
.

27 Jun 2013   #4
UsernameIssues

W7 Pro SP1 64bit
 
 

No need for 3rd party apps.
Command line will do it.

Open cmd prompt
type START /? and it enter
the switch of interest is /AFFINITY

A simple text batch file should be all you need to start an app at the desired affinity.

My System SpecsSystem Spec
28 Jun 2013   #5
MilesAhead

Windows 7 32 bit
 
 

Quote   Quote: Originally Posted by UsernameIssues View Post
No need for 3rd party apps.
Command line will do it.

Open cmd prompt
type START /? and it enter
the switch of interest is /AFFINITY

A simple text batch file should be all you need to start an app at the desired affinity.
Right, but if the app is already running then you're back to kill, then start etc..
If the batch is to be run only on the user's system then I see no problem with 3rd party software. However, if it's a homework assignment....
My System SpecsSystem Spec
28 Jun 2013   #6
GbeTech

Win7 Pro SP1 64
 
 

Hey thanks guys. Some great ideas there.
There is one caveat though, that prevents me from implementing them. I'm not sure it's 100% solvable:

It's an online game, that launches when I select a server from a 3rd party app. so I can't do the kill process-re-launch thing, because it will lose the server's IP.
It also means I'm not using a shortcut to the game's .exe.


I think the most reliable way is still through AHK - make sure the processes in task manager are sorted by name, count how many times I need to click the first letter so my process will be the top one, hope that no other processes with the same first letter are running, and simulate the mouse movements to set the affinity. Awkward!


I'll update you guys soon.
My System SpecsSystem Spec
28 Jun 2013   #7
GbeTech

Win7 Pro SP1 64
 
 

Okay got it!


EDIT: Doesn't work, refined code below.





It works, only if I don't have any additional "f" process running. Which I usually don't.
Thanks.
My System SpecsSystem Spec
28 Jun 2013   #8
UsernameIssues

W7 Pro SP1 64bit
 
 

Quote   Quote: Originally Posted by MilesAhead View Post
Quote   Quote: Originally Posted by UsernameIssues View Post
No need for 3rd party apps.
Command line will do it.

Open cmd prompt
type START /? and it enter
the switch of interest is /AFFINITY

A simple text batch file should be all you need to start an app at the desired affinity.
Right, but if the app is already running then you're back to kill, then start etc..
If the batch is to be run only on the user's system then I see no problem with 3rd party software. However, if it's a homework assignment....
That 3rd party app might indeed be better for the OP's situation since the app is already running. There might be a way to do it with start switches, but it is probably not worth the effort to figure out.

On XP, I used an add-on to task manager called PRIO. It was not very stable, once I found a version that worked I stuck with it. But you could set both Affinity and Priority levels for most any process and it would remember them for you. The next time that the app started, the process would use the settings that you last had the PRIO app remember.

But that was not the main reason why I used PRIO, it added a services tab to task manager and a TCP/IP tab that was like netstat outputs.



Quote   Quote: Originally Posted by GbeTech View Post
Okay got it!
~~~
It works, only if I don't have any additional "f" process running. Which I usually don't.
Thanks.
You can send more than one key to the Task Manager window to select a process. Keys sent in rapid susession are interpreted as refinements of the item to be selected, not other processes to locate. e.g. one can send "CL" to locate CLOCK.exe. The "L" should not take the selection down to processes that start with "L".

I would suggest that you try sending the complete name of the process to the Task Manager window. That works for me using AutoIt, it should work for you using AHK. (AHK is a fork of AutoIt.) I've used both AHK and AutoIt. I prefer the AutoIt app and script editor, but I don't like the AutoIt forum :-(

Also, most anything that you can do with mouse clicks can be done with sending keystrokes. Keystrokes are usually easier to replicate than mouse click locations.

For example:
Shift+F10 is the same as right-click in most cases.
You can use the arrow up or arrow down to select items from the context menu - or better yet, send keystrokes.

If you really want to dive into this - then you would call the native Windows Application Programming Interface (API) and set the Affinity that way... but that is beyond my skill level in AutoIt. You might find a post in AutoIt's forum where someone has already written a script to do just what you are doing - only they did it without interacting with any windows - via the API.
My System SpecsSystem Spec
28 Jun 2013   #9
GbeTech

Win7 Pro SP1 64
 
 

Quote   Quote: Originally Posted by UsernameIssues View Post
Quote   Quote: Originally Posted by MilesAhead View Post
Quote   Quote: Originally Posted by UsernameIssues View Post
No need for 3rd party apps.
Command line will do it.

Open cmd prompt
type START /? and it enter
the switch of interest is /AFFINITY

A simple text batch file should be all you need to start an app at the desired affinity.
Right, but if the app is already running then you're back to kill, then start etc..
If the batch is to be run only on the user's system then I see no problem with 3rd party software. However, if it's a homework assignment....
That 3rd party app might indeed be better for the OP's situation since the app is already running. There might be a way to do it with start switches, but it is probably not worth the effort to figure out.

On XP, I used an add-on to task manager called PRIO. It was not very stable, once I found a version that worked I stuck with it. But you could set both Affinity and Priority levels for most any process and it would remember them for you. The next time that the app started, the process would use the settings that you last had the PRIO app remember.

But that was not the main reason why I used PRIO, it added a services tab to task manager and a TCP/IP tab that was like netstat outputs.



Quote   Quote: Originally Posted by GbeTech View Post
Okay got it!
~~~
It works, only if I don't have any additional "f" process running. Which I usually don't.
Thanks.
You can send more than one key to the Task Manager window to select a process. Keys sent in rapid susession are interpreted as refinements of the item to be selected, not other processes to locate. e.g. one can send "CL" to locate CLOCK.exe. The "L" should not take the selection down to processes that start with "L".

I would suggest that you try sending the complete name of the process to the Task Manager window. That works for me using AutoIt, it should work for you using AHK. (AHK is a fork of AutoIt.) I've used both AHK and AutoIt. I prefer the AutoIt app and script editor, but I don't like the AutoIt forum :-(

Also, most anything that you can do with mouse clicks can be done with sending keystrokes. Keystrokes are usually easier to replicate than mouse click locations.

For example:
Shift+F10 is the same as right-click in most cases.
You can use the arrow up or arrow down to select items from the context menu - or better yet, send keystrokes.

If you really want to dive into this - then you would call the native Windows Application Programming Interface (API) and set the Affinity that way... but that is beyond my skill level in AutoIt. You might find a post in AutoIt's forum where someone has already written a script to do just what you are doing - only they did it without interacting with any windows - via the API.
Hey thanks a lot man.
You're probably right about using the keyboard instead of simulating mouse clicks. The power of habits I guess.
And I don't think I have the time to dive into all this API stuff... even that code I've written was actually a waste of time. I just couldn't resist the challenge I set myself haha.
My System SpecsSystem Spec
28 Jun 2013   #10
Brink

64-bit Windows 10 Pro
 
 

Hello GbeTech,

You might take a look at this to see if may help with what you are wanting to do. It allows you to set processor affinity via the context menu instead.

Processor Affinity - Add Set Affinity to Context Menu

Hope this may help,
Shawn
My System SpecsSystem Spec
Reply

 How to access "Processor Affinity" screen without Task Manager?




Thread Tools Search this Thread
Search this Thread:

Advanced Search




Similar help and support threads
Thread Forum
Force Task Manager "Show processes from all users" always enabled.
Is there a way to force Task Manager to open with the "Show processes from all users" option enabled? I created a shortcut and added "/1" (without quotes) in the property target line but it did not work. (I know, one click will accomplish this but I just like to tweak!) Disregard. Found...
General Discussion
Simpler access to "Task Manager"
When I want "TaskManager", it is often in an urgent situation ... ... like a lockup or when I want to see running services/apps immediately In WinXP Ctrl+Alt+Delete opened taskmgr.exe In Win7, Ctrl+Alt+Delete opens an intermediate screen with 7 options of which only one is "Start Task...
Performance & Maintenance
The "Applications" screen in Task Manager has disappeared!
When I launch Task Manager, the only screen I have access to is the Processes screen - and I do not have any options to see what applications are running, or anything other than which processes are running, which makes it much more difficult to determine what's going on with my PC. I have run...
General Discussion
how to save my affinity setting in task manager
hello all i want to change my affinity settings in task manager but when i restart the pc it change as it was before so is their anything i can do to save the affinity like program or something ? my pc is windows 7 64 bit thank you all
Performance & Maintenance
"Windows Task Manager has stopped working" anytime I try to run it
Hello, I'd be very glad if anyone could help me. My OS version is Windows 7 Home Premium 64bit. Whenever I try to run the task manager, either by pressing Alt+Ctrl+Del and selecting it or right clicking on the task bar, the window opens but immediately an error is displayed "Windows Task...
BSOD Help and Support
How to default the "SHOW PROCESSES FOR ALL USERS" in task manager
Using TASK MANAGER, as I frequently do, under w7 I have to re-check the SHOW PROCESSES FOR ALL USERS button each time I restart TASK MANAGER. Is there a way to force it to default to showing all users? Thanks
Performance & Maintenance


Our Sites

Site Links

About Us

Find Us

Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd

All times are GMT -5. The time now is 13:05.

Twitter Facebook Google+



Windows 7 Forums

Seven Forums Android App Seven Forums IOS App