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

Page 1 of 2 12 LastLast

  1. Posts : 15
    Win7 Pro SP1 64
       #1

    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 Computer


  2. Posts : 210
    Microsoft Windows 7 Ultimate 64-bit 7601 Multiprocessor Free Service Pack 1
       #2

    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 Computer


  3. Posts : 5,092
    Windows 7 32 bit
       #3

    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 Computer


  4. Posts : 10,485
    W7 Pro SP1 64bit
       #4

    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.

    Last edited by UsernameIssues; 27 Jun 2013 at 14:47.
      My Computer


  5. Posts : 5,092
    Windows 7 32 bit
       #5

    UsernameIssues said:
    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 Computer


  6. Posts : 15
    Win7 Pro SP1 64
    Thread Starter
       #6

    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 Computer


  7. Posts : 15
    Win7 Pro SP1 64
    Thread Starter
       #7

    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.
    Last edited by GbeTech; 30 Jun 2013 at 07:14.
      My Computer


  8. Posts : 10,485
    W7 Pro SP1 64bit
       #8

    MilesAhead said:
    UsernameIssues said:
    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.



    GbeTech said:
    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 Computer


  9. Posts : 15
    Win7 Pro SP1 64
    Thread Starter
       #9

    UsernameIssues said:
    MilesAhead said:
    UsernameIssues said:
    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.



    GbeTech said:
    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 Computer


  10. Posts : 71,977
    64-bit Windows 11 Pro for Workstations
       #10

    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 Computer


 
Page 1 of 2 12 LastLast

  Related Discussions
Our Sites
Site Links
About 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 23:40.
Find Us