Desktop or Laptop ?
-
- Posts: 136
- Joined: 06 May 2020, 17:16
Desktop or Laptop ?
I don't know if this is possible, but can a script detect if its desktop, do this, then if its laptop, do that ?
Re: Desktop or Laptop ?
Yes. You simply need to define each of them first!
Examples could be using a screen resolution, or a computer name of your choosing. A computer is a computer-- different shapes and sizes-- but your own situation might (and probably does) have some distinguishing features. Does one have a battery, and the other not have a battery? That can be a way to tell. Wi-Fi vs. no Wi-Fi. Etc.
Examples could be using a screen resolution, or a computer name of your choosing. A computer is a computer-- different shapes and sizes-- but your own situation might (and probably does) have some distinguishing features. Does one have a battery, and the other not have a battery? That can be a way to tell. Wi-Fi vs. no Wi-Fi. Etc.
- flyingDman
- Posts: 2832
- Joined: 29 Sep 2013, 19:01
Re: Desktop or Laptop ?
Try:
This worked on my laptop but do not have a desktop to test.
edit added a clipwait
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"
}
edit added a clipwait
Last edited by flyingDman on 03 Apr 2024, 22:23, edited 1 time in total.
14.3 & 1.3.7
-
- Posts: 136
- Joined: 06 May 2020, 17:16
Re: Desktop or Laptop ?
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"
Re: Desktop or Laptop ?
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"
- flyingDman
- Posts: 2832
- Joined: 29 Sep 2013, 19:01
Re: Desktop or Laptop ?
labels ?
Perhaps this will help:
The exact list is:
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 - Hand Held
12 - Docking Station
13 - All in One
14 - Sub Notebook
15 - Space-Saving
16 - Lunch Box
17 - Main System Chassis
18 - Expansion Chassis
19 - SubChassis
20 - Bus Expansion Chassis
21 - Peripheral Chassis
22 - Storage Chassis
23 - Rack Mount Chassis
24 - Sealed-Case PC
30 - Tablet
31 - Convertible
32 - Detachable
Perhaps this will help:
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"
}
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 - Hand Held
12 - Docking Station
13 - All in One
14 - Sub Notebook
15 - Space-Saving
16 - Lunch Box
17 - Main System Chassis
18 - Expansion Chassis
19 - SubChassis
20 - Bus Expansion Chassis
21 - Peripheral Chassis
22 - Storage Chassis
23 - Rack Mount Chassis
24 - Sealed-Case PC
30 - Tablet
31 - Convertible
32 - Detachable
14.3 & 1.3.7
Re: Desktop or Laptop ?
That's cool. Here is just another way to do the same thing.
Get chassis type
Get chassis type
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]
}
Re: Desktop or Laptop ?
Does it need to detect any laptop vs desktop, or is it just your one laptop vs your one desktop? If you only care about specific ones (as Mike suggested) you might use the built in variable A_ComputerName.
ste(phen|ve) kunkel
-
- Posts: 136
- Joined: 06 May 2020, 17:16
Re: Desktop or Laptop ?
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 ?
Re: Desktop or Laptop ?
Your question has now changed from the original one. You are probably better off using a MachineGuid, but if you want the UUID, it is below. As noted, if you control these computers and set the computer name (or they simply have unique names), then that would be sufficient to distinguish all of them.
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
}
-
- Posts: 136
- Joined: 06 May 2020, 17:16
Re: Desktop or Laptop ?
I am currently using my desktop aka ASUS3, I am trying to set volume for ASUS3, but dell1 and dell2 audio devices don't exist in my desktop which is normal. A popup says Error: Device not found . Is it possible to ignore that warning and let script run with no popup ?
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
}
- flyingDman
- Posts: 2832
- Joined: 29 Sep 2013, 19:01
Re: Desktop or Laptop ?
Your issue is with the if and {} blocks (or lack thereof)
Also (because your UUID look real)
Also (because your UUID look real)
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.
14.3 & 1.3.7
-
- Posts: 136
- Joined: 06 May 2020, 17:16
Re: Desktop or Laptop ?
Thankyou for the warning. I did not know that......
Who is online
Users browsing this forum: No registered users and 42 guests