Desktop or Laptop ?
Posted: 03 Apr 2024, 21:42
I don't know if this is possible, but can a script detect if its desktop, do this, then if its laptop, do that ?
Let's help each other out
https://www.autohotkey.com/boards/
https://www.autohotkey.com/boards/viewtopic.php?f=82&t=128253
Code: Select all
a_clipboard := ""
Run a_comspec ' /c wmic systemenclosure get chassistypes | clip',,'hide'
if ClipWait(1)
{
regexmatch(a_clipboard, "(\d+)",&m)
msgbox (m[1] = 9 or m[1] = 10) ? "laptop" : "desktop"
}
How do I make labels to assign commands if its desktop vs laptop ?flyingDman wrote: ↑03 Apr 2024, 22:10Try:This worked on my laptop but do not have a desktop to test.Code: Select all
Run a_comspec ' /c wmic systemenclosure get chassistypes | clip',,'hide' regexmatch(a_clipboard, "(\d+)",&m) msgbox (m[1] = 9 or m[1] = 10) ? "laptop" : "desktop"
Works fine on my desktop.flyingDman wrote: ↑03 Apr 2024, 22:10Try:This worked on my laptop but do not have a desktop to test.Code: Select all
Run a_comspec ' /c wmic systemenclosure get chassistypes | clip',,'hide' regexmatch(a_clipboard, "(\d+)",&m) msgbox (m[1] = 9 or m[1] = 10) ? "laptop" : "desktop"
Code: Select all
a_clipboard := ""
Run a_comspec ' /c wmic systemenclosure get chassistypes | clip',,'hide'
if ClipWait(1)
{
regexmatch(a_clipboard, "(\d+)",&m)
if (m[1] = 9 or m[1] = 10)
msgbox "this is a laptop"
else
msgbox "this is a desktop"
}
Code: Select all
#Requires AutoHotkey v2.0
MsgBox chassisType(), 'Chassis type', 'Iconi'
chassisType() {
Static chassis := Map(
1, 'Other'
, 2, 'Unknown'
, 3, 'Desktop'
, 4, 'Low-profile desktop'
, 5, 'Pizza box'
, 6, 'Mini tower'
, 7, 'Tower'
, 8, 'Portable'
, 9, 'Laptop'
, 10, 'Notebook'
, 11, 'Handheld'
, 12, 'Docking station'
, 13, 'All in one'
, 14, 'Sub-notebook'
, 15, 'Space-saving'
, 16, 'Lunchbox'
, 17, 'Main system chassis'
, 18, 'Expansion chassis'
, 19, 'Sub-chassis'
, 20, 'Bus expansion chassis'
, 21, 'Peripheral chassis'
, 22, 'Storage chassis'
, 23, 'Rack-mount chassis'
, 24, 'Sealed-case PC'
, 30, 'Tablet'
, 31, 'Convertible'
, 32, 'Detachable'
)
queryEnum := ComObjGet('winmgmts:').ExecQuery('Select * from Win32_SystemEnclosure')._NewEnum()
If queryEnum(&p)
For t in p.ChassisTypes
Return chassis[t]
}
I have 2 DELL laptops and 1 desktop. I read that a precise way to differentiate the 2 laptops is by using its UUID, which is obtained by cmd command wmic csproduct get uuid. I often have to reinstall windows so ComputerName is not reliable. How do I put all this in a script where if it UUID matches certain DELL laptop, run this command, if the other, run some other command ?
Code: Select all
#Requires AutoHotkey v2.0
dell1 := '123456'
dell2 := 'abcdefg'
MsgBox uuid(), 'UUID', 'Iconi'
If uuid() = dell1
MsgBox 1
Else MsgBox 2
uuid() {
queryEnum := ComObjGet('winmgmts:').ExecQuery('Select * from Win32_ComputerSystemProduct')._NewEnum()
If queryEnum(&p)
Return p.UUID
}
Code: Select all
#Requires AutoHotkey v2.0
dell1 := '827583f0-8fe7-417b-8a81-94641f0eb324'
dell2 := '9afd4898-2154-4ccb-98da-1f3abfbc408a'
ASUS3 := '28f11e28-6c02-76eb-8ea5-da9772715135'
MsgBox uuid(), 'UUID', 'Iconi'
If uuid() = dell1
MsgBox 1
SoundSetVolume "20", , "Speakers (Realtek(R) Audio)"
If uuid() = dell2
MsgBox 2
SoundSetVolume "30", , "Intel (Realtek(L) Audio)"
If uuid() = ASUS3
MsgBox 3
SoundSetVolume "20", , "MX279 (Intel(R) Display Audio)"
uuid() {
queryEnum := ComObjGet('winmgmts:').ExecQuery('Select * from Win32_ComputerSystemProduct')._NewEnum()
If queryEnum(&p)
Return p.UUID
}
There are a few reasons why you should not post your UUID online. First, it could be used to track you across multiple websites and services. Second, it could be used to identify you if you are using a service that uses UUIDs to authenticate users. Third, it could be used to link your online activity to your real-world identity if you have ever used your UUID in a public setting.
If you need to share a UUID with someone, it is best to do so in a private message or email. You should also avoid posting your UUID on social media or other public websites.