Jump to content

How to get the current hardware profile.


Recommended Posts

I'm trying to make a script to check what the current hardware profile is and evaluate the number of profiles currently loaded.

How do i get the actual current hardware profile?

This is as far as i've gotten. It opens the Hardware Profiles dialog, resizes and moves it.

send("#M")
send("#e")
Sleep(1000)
send("{appskey}")
Sleep(1000)
send("{up}")
Sleep(1000)
send("{enter}")
Sleep(1000)
send("{!tab}")
Sleep(1000)
if WinActivate("My Computer")=true Then WinClose("My Computer")
Sleep(1000)
send("{right 2}")
sleep(1000)
send ("!p")
Sleep(1000)
WinMove("Hardware Profiles", "", 0, 0, 400, 400)
Link to comment
Share on other sites

This is very quick and dirty, but it works on my laptop:

dim $profile
$current = regread('HKLM\SYSTEM\ControlSet001\Control\IDConfigDB', 'CurrentConfig')
if @error then msgbox(0, 'Test', 'failed')
for $i = 1 to 10
    $key = regenumkey('HKLM\SYSTEM\ControlSet001\Control\IDConfigDB\Hardware Profiles\', $i)
    if @error then continueloop
    if stringright($key, 1) == $current then
        $profile = regread('HKLM\SYSTEM\ControlSet001\Control\IDConfigDB\Hardware Profiles\' & $key, 'FriendlyName')
        msgbox(0, 'Test', 'Current Profile: ' & $profile)
    endif
;if @error then
;msgbox(0, 'Test', 'failed')
next
if not $profile then msgbox(0, 'Test', 'failed')

It's pulling the value from the registry rather than the GUI. If you have more than 9 profiles, it won't work (thought the code could be modified to support that).

Also, if you prefer to go through the GUI (which may be more reliable; I've never messed with hardware profiles before), you can open the Hardware Profiles dialog much more easily than you're doing above:

run('rundll32.exe shell32.dll,Control_RunDLL sysdm.cpl,,2')
winwaitactive('System Properties')
send('!p')
Link to comment
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
 Share

  • Recently Browsing   0 members

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