Basic information about your computer Topic is solved

Get help with using AutoHotkey and its commands and hotkeys
Rami
Posts: 55
Joined: 19 May 2016, 07:44

Basic information about your computer

07 Nov 2016, 09:27

Hi,
What i'm trying to make is GUI AHK script, but i would like to show some information about the computer on the top of its interface.
Something not more than showing the info in System properties (right click on My Computer > Properties)

Any idea, help, or code to get any of these information written in GUI Text is appreciated.

Thank you
Rami
Posts: 55
Joined: 19 May 2016, 07:44

Re: Basic information about your computer

07 Nov 2016, 10:16

I could get:
Windows 7 Professional
Service Pack 1
Version 6.1

reading the registry

Here is the code:

Code: Select all

RegRead, ProductName, HKEY_LOCAL_MACHINE, SOFTWARE\Microsoft\Windows NT\CurrentVersion, ProductName
RegRead, CSDVersion, HKLM, SOFTWARE\Microsoft\Windows NT\CurrentVersion, CSDVersion
RegRead, CurrentVersion, HKLM, SOFTWARE\Microsoft\Windows NT\CurrentVersion, CurrentVersion

MsgBox, ProductName: "%ProductName%"`n
and CSDVersion: "%CSDVersion%"`n
and CurrentVersion: "%CurrentVersion%"`n
I think i'm going in the right way, and I will find the memory and the CPU info.
Last edited by Rami on 07 Nov 2016, 12:17, edited 1 time in total.
Rami
Posts: 55
Joined: 19 May 2016, 07:44

Re: Basic information about your computer

07 Nov 2016, 10:42

By mixing couple solutions found in forum I ended up with the following code:

Code: Select all

RegRead, ProductName, HKEY_LOCAL_MACHINE, SOFTWARE\Microsoft\Windows NT\CurrentVersion, ProductName

If ( OSVersion := GetOSVersionInfo() )
	MsgBox % "ProductName`t:`t" . ProductName
		. "`nOS Version`t:`t" OSVersion.EasyVersion
		. "`nOS Service pack`t:`t" . OSVersion.ServicePackString

GetOSVersionInfo() {
	static Ver
	If !Ver
	{
		VarSetCapacity(OSVer, 284, 0)
		NumPut(284, OSVer, 0, "UInt")
		If !DllCall("GetVersionExW", "Ptr", &OSVer)
			return 0 ; GetSysErrorText(A_LastError)
		Ver := Object()
		Ver.MajorVersion      := NumGet(OSVer, 4, "UInt")
		Ver.MinorVersion      := NumGet(OSVer, 8, "UInt")
		Ver.BuildNumber       := NumGet(OSVer, 12, "UInt")
		Ver.PlatformId        := NumGet(OSVer, 16, "UInt")
		Ver.ServicePackString := StrGet(&OSVer+20, 128, "UTF-16")
		Ver.ServicePackMajor  := NumGet(OSVer, 276, "UShort")
		Ver.ServicePackMinor  := NumGet(OSVer, 278, "UShort")
		Ver.SuiteMask         := NumGet(OSVer, 280, "UShort")
		Ver.ProductType       := NumGet(OSVer, 282, "UChar")
		Ver.EasyVersion       := Ver.MajorVersion . "." . Ver.MinorVersion . "." . Ver.BuildNumber
	}
	return Ver
}
That returns:
  • ProductName : Windows 7 Professional
    OS Version : 6.1.7601
    OS Service Pack : Service Pack 1
Rami
Posts: 55
Joined: 19 May 2016, 07:44

Re: Basic information about your computer

07 Nov 2016, 12:21

My final part of the script after few collections from the forum and simple addition by me if someone will need this info: (no credit to me)

Code: Select all

#Persistent
#SingleInstance, force
#NoEnv
#WinActivateForce

SetBatchLines -1
SetWorkingDir %A_ScriptDir%

RegRead, ProductName, HKEY_LOCAL_MACHINE, SOFTWARE\Microsoft\Windows NT\CurrentVersion, ProductName
GMSEx := GlobalMemoryStatusEx()
GMSExM01 := Round(GMSEx[2] / 1024**2, 2)

If ( OSVersion := GetOSVersionInfo() )
	MsgBox % "ProductName`t:`t" . ProductName
		. "`nOS Version`t:`t" OSVersion.EasyVersion
		. "`nOS Service pack`t:`t" . OSVersion.ServicePackString
		. "`nComputer Name`t:`t" . a_computername
		. "`nUser Name`t:`t" . a_username
		. "`nIP Address`t`t:`t" . a_ipaddress1
		. "`nPhysical Memory`t:`t" . GMSExM01 MB

; ***** FUNCTIONS *****
GetOSVersionInfo() {
	static Ver
	If !Ver
	{
		VarSetCapacity(OSVer, 284, 0)
		NumPut(284, OSVer, 0, "UInt")
		If !DllCall("GetVersionExW", "Ptr", &OSVer)
			return 0 ; GetSysErrorText(A_LastError)
		Ver := Object()
		Ver.MajorVersion      := NumGet(OSVer, 4, "UInt")
		Ver.MinorVersion      := NumGet(OSVer, 8, "UInt")
		Ver.BuildNumber       := NumGet(OSVer, 12, "UInt")
		Ver.PlatformId        := NumGet(OSVer, 16, "UInt")
		Ver.ServicePackString := StrGet(&OSVer+20, 128, "UTF-16")
		Ver.ServicePackMajor  := NumGet(OSVer, 276, "UShort")
		Ver.ServicePackMinor  := NumGet(OSVer, 278, "UShort")
		Ver.SuiteMask         := NumGet(OSVer, 280, "UShort")
		Ver.ProductType       := NumGet(OSVer, 282, "UChar")
		Ver.EasyVersion       := Ver.MajorVersion . "." . Ver.MinorVersion . "." . Ver.BuildNumber
	}
	return Ver
}

GlobalMemoryStatusEx() {
	static MEMORYSTATUSEX, init := VarSetCapacity(MEMORYSTATUSEX, 64, 0) && NumPut(64, MEMORYSTATUSEX, "UInt")
	if (DllCall("Kernel32.dll\GlobalMemoryStatusEx", "Ptr", &MEMORYSTATUSEX))
	{
		return { 2 : NumGet(MEMORYSTATUSEX, 8, "UInt64")
        , 3 : NumGet(MEMORYSTATUSEX, 16, "UInt64")
        , 4 : NumGet(MEMORYSTATUSEX, 24, "UInt64")
        , 5 : NumGet(MEMORYSTATUSEX, 32, "UInt64") }
	}
}
Ok, now i think i need help only with displaying these results in beautiful way into the top of my GUI as information (instead of MsgBox in my script). Any help with that is appreciated.
garry
Posts: 1885
Joined: 22 Dec 2013, 12:50

Re: Basic information about your computer  Topic is solved

07 Nov 2016, 14:19

added GUI

Code: Select all

;-------- saved at Montag, 7. November 2016 19:32:14 --------------
;-------- https://autohotkey.com/boards/viewtopic.php?f=5&t=24404 ---

#Persistent
SetWorkingDir, %A_ScriptDir%
SetBatchLines, -1

Gui,2:default
Gui,2:Color, Black
Gui,2:Color, ControlColor, Black
Gui,2:Font,cYellow,Fixedsys


Gui,2:Add,Text , x220   y10   ,ProductName
Gui,2:Add,Text , x220   y40   ,OS Version
Gui,2:Add,Text , x220   y70   ,OS Service Pack
Gui,2:Add,Text , x220   y100  ,Computer Name
Gui,2:Add,Text , x220   y130  ,Username
Gui,2:Add,Text , x220   y160  ,IP-Adress
Gui,2:Add,Text , x220   y190  ,Physical Memory

Gui,2:Add,Edit , x10   y10  w200 h25 vED1 cRed   readonly right,
Gui,2:Add,Edit , x10   y40  w200 h25 vED2        readonly right,
Gui,2:Add,Edit , x10   y70  w200 h25 vED3        readonly right,
Gui,2:Add,Edit , x10   y100 w200 h25 vED4        readonly right,
Gui,2:Add,Edit , x10   y130 w200 h25 vED5 cGreen readonly right,
Gui,2:Add,Edit , x10   y160 w200 h25 vED6        readonly right,
Gui,2:Add,Edit , x10   y190 w200 h25 vED7 cTeal  readonly right,
Gui,2:show, x100 y10 w500 h250 ,Computer-Info
gosub,a0
return
2Guiclose:
exitapp

a0:
RegRead, ProductName, HKEY_LOCAL_MACHINE, SOFTWARE\Microsoft\Windows NT\CurrentVersion, ProductName
GMSEx := GlobalMemoryStatusEx()
GMSExM01 := Round(GMSEx[2] / 1024**2, 2)
If ( OSVersion := GetOSVersionInfo() )
 GuiControl, 2:, ED1, % productname
 GuiControl, 2:, ED2, % OSVersion.EasyVersion
 GuiControl, 2:, ED3, % OSVersion.ServicePackString
 GuiControl, 2:, ED4, % a_computername
 GuiControl, 2:, ED5, % a_username
 GuiControl, 2:, ED6, % a_ipaddress1
 GuiControl, 2:, ED7, % GMSExM01 MB

/*
	MsgBox % "ProductName`t:`t" . ProductName
		. "`nOS Version`t:`t" OSVersion.EasyVersion
		. "`nOS Service pack`t:`t" . OSVersion.ServicePackString
		. "`nComputer Name`t:`t" . a_computername
		. "`nUser Name`t:`t" . a_username
		. "`nIP Address`t`t:`t" . a_ipaddress1
		. "`nPhysical Memory`t:`t" . GMSExM01 MB
*/

; ***** FUNCTIONS *****
GetOSVersionInfo() {
        static Ver
	If !Ver
	{
		VarSetCapacity(OSVer, 284, 0)
		NumPut(284, OSVer, 0, "UInt")
		If !DllCall("GetVersionExW", "Ptr", &OSVer)
			return 0 ; GetSysErrorText(A_LastError)
		Ver := Object()
		Ver.MajorVersion      := NumGet(OSVer, 4, "UInt")
		Ver.MinorVersion      := NumGet(OSVer, 8, "UInt")
		Ver.BuildNumber       := NumGet(OSVer, 12, "UInt")
		Ver.PlatformId        := NumGet(OSVer, 16, "UInt")
		Ver.ServicePackString := StrGet(&OSVer+20, 128, "UTF-16")
		Ver.ServicePackMajor  := NumGet(OSVer, 276, "UShort")
		Ver.ServicePackMinor  := NumGet(OSVer, 278, "UShort")
		Ver.SuiteMask         := NumGet(OSVer, 280, "UShort")
		Ver.ProductType       := NumGet(OSVer, 282, "UChar")
		Ver.EasyVersion       := Ver.MajorVersion . "." . Ver.MinorVersion . "." . Ver.BuildNumber
	}
	return Ver
}
GlobalMemoryStatusEx() {
	static MEMORYSTATUSEX, init := VarSetCapacity(MEMORYSTATUSEX, 64, 0) && NumPut(64, MEMORYSTATUSEX, "UInt")
	if (DllCall("Kernel32.dll\GlobalMemoryStatusEx", "Ptr", &MEMORYSTATUSEX))
	{
		return { 2 : NumGet(MEMORYSTATUSEX, 8, "UInt64")
        , 3 : NumGet(MEMORYSTATUSEX, 16, "UInt64")
        , 4 : NumGet(MEMORYSTATUSEX, 24, "UInt64")
        , 5 : NumGet(MEMORYSTATUSEX, 32, "UInt64") }
	}
}
return
Rami
Posts: 55
Joined: 19 May 2016, 07:44

Re: Basic information about your computer

07 Nov 2016, 14:27

Thanks a lot!
Actually I started doing GUI through AutoGUI v1.1.6 found it here. but you saved me a lot of hours !

I appreciate your time!
garry
Posts: 1885
Joined: 22 Dec 2013, 12:50

Re: Basic information about your computer

07 Nov 2016, 16:03

a_variables
https://autohotkey.com/docs/Variables.htm
example , click column to open appdatacommon etc...

Code: Select all

MODIFIED=20160703
;- A_VARIABLE
;- https://autohotkey.com/docs/Variables.htm
;------------------------------------------------------------------------
#NoEnv              ; Recommended for performance and compatibility with future AutoHotkey releases.
#Warn
SendMode Input      ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir, %A_ScriptDir%
SetTitleMatchMode 2
SetBatchLines, -1

FormatTime, Suomi , L1035, dddd MMMM yyyy-MM-dd
Filename1=AHK-A_Variables      User=%a_username%        Computer=%a_computername%        %a_osversion%       AHK-Version=%a_ahkversion%       %suomi%

url=http://www.netikus.net/show_ip.html   ;- to show public IP-address
Adr:= UrlDownloadToVar( URL )             ;- desactivate this when no internetconnection

Gui,2:default
Gui,2: -DPIScale
Gui,2:Font,s12 , Lucida Console
Gui,2:Color,Black

wa:=A_screenwidth
ha:=A_screenHeight

LH :=(ha*89  )/100  ;- LV  height
GH :=(ha*93  )/100  ;- GUI height
LW :=(wa*98.5)/100  ;- LV  width
GW :=(wa*99  )/100  ;- GUI width

T1 :=(wa*12)/100
T2 :=(wa*10)/100
T3 :=(wa*75)/100

t2a:=(t1+t2)

Gui,2: Add, ListView,grid backgroundGray cWhite x2 y2 h%LH% w%lw% gMyLV1 vLV1 +altsubmit -multi, Name|AHK-A_Variable|Show Result ( open Info/Folder/File/URL with mouse-click )
LV_ModifyCol(1, T1), LV_ModifyCol(2, T2), LV_ModifyCol(3, T3)             ;- column width

Gui,2:show,x1 y1 h%gh% w%gw%,%filename1%

gosub,smalltools
gosub,e4xvar
e5x:= % ShellFolder()
e6x=%e4x%%e5x%

gosub,fillx
return

FileExit:
2Guiclose:
exitapp
;--------------------------


fillx:
Gui,2:submit,nohide
Gui,2:ListView, LV1
LV_Delete()
GuiControl, -Redraw, LV1
loop,parse,e6x,`n,`r
   {
   y=%a_loopfield%
   if y=
     continue
   LV_Add("", StrSplit(y,",")*)
   }
LV_ModifyCol(1, "Logical SortAsc")
GuiControl, +Redraw, LV1
return
;----------------------------

mylv1:
Gui,2:ListView, LV1
if A_GuiEvent = Normal
 {
 LV_GetText(C1,A_EventInfo,1)
 LV_GetText(C2,A_EventInfo,2)
 LV_GetText(C3,A_EventInfo,3)
 stringmid,C3a,C3,2,2
 stringmid,C3b,C3,1,2
 stringmid,C3c,C3,1,4
 MouseGetPos,x,y
 {
;if x>%T2a%
    {
    if (c3a=":\" or c3b="::" or c3c="http" or c3c="www.")
       {
       run,%c3%
       return
       }
      else
       {
       msgbox, 262208,INFO ,C1=%c1%`nC2=%c2%`nC3=%c3%
       return
       }
  return
     }
  }
 }
return
;-------------------------------



smalltools:
SysGet, VirtualWidth , 78
SysGet, VirtualHeight, 79
EnvGet, EnvGetVar, Path  ;- see #Noenv
return


;-------- http://www.autohotkey.com/forum/topic36688.html ---
;MsgBox  % ShellFolder()                  ; To retrieve all
;MsgBox  % ShellFolder( "My Pictures" )   ; To retrieve Pictures folder
;return

ShellFolder( VN="" ) {
v:=""
Static Subkey:="Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders"
 If ( VN="")
 {
 Loop, HKCU, %SubKey%, 0
    {  VarSetCapacity( Spaces,30,32 )
       RegRead, Value, HKCU, %SubKey%, %A_LoopRegName%
       v .= ((v<>"") ? "`n" : "" ) (A_LoopRegName) ",RegRead," Value
    }
 } Else
 RegRead, V, HKCU, %SubKey%, %VN%
Return V
}


UrlDownloadToVar(URL) {
 WebRequest := ComObjCreate("WinHttp.WinHttpRequest.5.1")
 WebRequest.Open("GET", URL)
 WebRequest.Send()
 Return WebRequest.ResponseText
}


e4xVar:
e4x=
(
_A-Variables,,https://autohotkey.com/docs/Variables.htm
MyComputer,CLSID,::{20d04fe0-3aea-1069-a2d8-08002b30309d}
MyNetworkPlaces,CLSID,::{208d2c60-3aea-1069-a2d7-08002b30309d}
NetworkConnections,CLSID,::{7007acc7-3202-11d1-aad2-00805fc1270e}
Printers,CLSID,::{2227a280-3aea-1069-a2de-08002b30309d}
RecycleBin,CLSID,::{645ff040-5081-101b-9f08-00aa002f954e}
ScheduledTasks,CLSID,::{d6277990-4c6a-11cf-8d87-00aa0060f5bf}
ahk-Version,a_ahkversion,%a_ahkversion%
unicode,a_IsUnicode,%a_IsUnicode%
ipaddress-1 private,a_ipaddress1,%a_ipaddress1%
ipaddress-2,a_ipaddress2,%a_ipaddress2%
ipaddress-3,a_ipaddress3,%a_ipaddress3%
ipaddress-4,a_ipaddress4,%a_ipaddress4%
ipaddress-0 public,www.netikus.net,%adr%
64-bit,a_Is64bitOS,%a_Is64bitOS%
ahk-path,a_ahkpath,%a_ahkpath%
ahk-scriptfullpath,a_scriptfullpath,%a_scriptfullpath%
ahk-HWND,a_scriptHwnd,%a_scriptHwnd%
ptr-size,a_ptrsize,%a_ptrsize%
appdata,a_appdata,%a_appdata%
appdatacommon,a_appdatacommon,%a_appdatacommon%
personal mydocuments,a_mydocuments,%a_mydocuments%
programfiles,a_programfiles,%a_programfiles%
programs,a_programs,%a_programs%
programsCommon,a_programsCommon,%a_programsCommon%
start Menu,a_StartMenu,%a_StartMenu%
startMenuCommon,a_StartMenuCommon,%a_StartMenuCommon%
startup,a_Startup,%a_Startup%
startupCommon,a_StartupCommon,%a_StartupCommon%
temp,a_Temp,%a_Temp%
username,a_username,%a_username%
DATE,a_YYYY-A_MM-a_DD a_hour:a_min:a_sec,%A_YYYY%-%A_MM%-%a_DD% %a_hour%:%a_min%:%a_sec%
DATE_NOW,a_now,%a_now%
DATE_UTC,a_nowUTC,%a_nowUTC%
DATE_Weekday,a_wday,%a_wday%
desktop,a_desktop,%a_desktop%
desktopcommon,a_desktopcommon,%a_desktopcommon%
computername,a_computername,%a_computername%
windir,a_windir,%a_windir%
language,a_language,%a_language%
iconhidden,a_iconhidden,%a_iconhidden%
ahk-scriptworkingdir,a_workingdir,%a_workingdir%
admin,a_IsAdmin,%a_IsAdmin%
osType,a_OsType,%a_OsType%
osversion,a_osversion,%a_osversion%
os64bit,a_Is64bitOS,%a_Is64bitOS%
MouseSpeed,a_defaultmousespeed,%a_defaultmousespeed%
GUI,a_defaultgui,%a_defaultgui%
Listview,a_defaultListview,%a_defaultListview%
ScreenWidthVirtual,,%VirtualWidth%
ScreenHeightVirtual,,%VirtualHeight%
ScreenWidth,a_ScreenWidth,%a_ScreenWidth%
ScreenHeight,a_ScreenHeight,%a_ScreenHeight%
ScreenDPI,a_ScreenDPI,%a_ScreenDPI%
ErrorLast,a_LastError,%a_LastError%
Envget,Envget,_%envgetvar%
cmd command,comspec,%comspec%
Encoding,a_FileEncoding,%a_FileEncoding%
Compiled,a_iscompiled,%a_iscompiled%
ahk-ScriptName,a_scriptname,%a_scriptname%
ahk-ScriptDir,a_scriptdir,%a_scriptdir%
Workingdir,a_workingdir,%a_workingdir%
Critical,a_IsCritical,%a_IsCritical%


)
return

;================= END script ===========================
added WLAN-password to your script above , from user RickC
https://autohotkey.com/boards/viewtopic.php?f=6&t=24202

Code: Select all

;-------- https://autohotkey.com/boards/viewtopic.php?f=5&t=24404 ---

#Persistent
SetWorkingDir, %A_ScriptDir%
SetBatchLines, -1

Gui,2:default
Gui,2: -dpiscale
Gui,2:Color, Black
Gui,2:Color, ControlColor, Black
;Gui,2:Font,cYellow,Fixedsys
Gui,2:Font,cYellow s12,Lucida Console


Gui,2:Add,Text , x270   y10   ,ProductName
Gui,2:Add,Text , x270   y50   ,OS Version
Gui,2:Add,Text , x270   y90   ,OS Service Pack
Gui,2:Add,Text , x270   y130  ,Computer Name
Gui,2:Add,Text , x270   y170  ,Username
Gui,2:Add,Text , x270   y210  ,IP-Adress
Gui,2:Add,Text , x270   y250  ,Physical Memory
Gui,2:Add,Text , x270   y290  ,WLAN-Name
Gui,2:Add,Text , x270   y330  ,WLAN-Password

Gui,2:Add,Edit , x10   y10  w250 h30 vED1 cRed   readonly right,
Gui,2:Add,Edit , x10   y50  w250 h30 vED2        readonly right,
Gui,2:Add,Edit , x10   y90  w250 h30 vED3        readonly right,
Gui,2:Add,Edit , x10   y130 w250 h30 vED4        readonly right,
Gui,2:Add,Edit , x10   y170 w250 h30 vED5 cGreen readonly right,
Gui,2:Add,Edit , x10   y210 w250 h30 vED6        readonly right,
Gui,2:Add,Edit , x10   y250 w250 h30 vED7        readonly right,
Gui,2:Add,Edit , x10   y290 w250 h30 vED8 cTeal  readonly right,
Gui,2:Add,Edit , x10   y330 w250 h30 vED9 cTeal  readonly right,

Gui,2:show, x100 y10 w600 h400 ,Computer-Info
gosub,a0
gosub,a1
return
2Guiclose:
exitapp

a1:
;-WLAN password Windows10
;-https://autohotkey.com/boards/viewtopic.php?f=6&t=24202
fd=%a_scriptdir%\WifiXMLS
ifnotexist,%fd%
  filecreatedir,%fd%

RunWait, %comspec% /c "netsh wlan export profile folder=%fd% key=clear",, hide  ;- Exports all WiFi profile

Loop, %fd%\*.xml
  {
  aac:=""
  y:=A_LoopFileFullPath           ;- this is a xml-file in folder above
  fileread,aac,%y%                ;- read txt-file to memory
  Loop,parse,aac,`n,`r            ;- parse each line by `n ascii-10
    {
    x:= A_LoopField               ;- line in xml-file
    if x contains <name>
       L1:=RegExReplace( x, "<.*?>" )
    if x contains <keyMaterial>
       {
       L2:=RegExReplace( x, "<.*?>" )
       L1=%L1%
       L2=%L2%
       ;e4 .= "SSID=" . L1 "`nPassword=" . L2 . "`nXML-File=" . y . "`n----------------"
       }
    }
  }
GuiControl, 2:, ED8, %L1%
GuiControl, 2:, ED9, %L2%
return


a0:
RegRead, ProductName, HKEY_LOCAL_MACHINE, SOFTWARE\Microsoft\Windows NT\CurrentVersion, ProductName
GMSEx := GlobalMemoryStatusEx()
GMSExM01 := Round(GMSEx[2] / 1024**2, 2)
If ( OSVersion := GetOSVersionInfo() )
 GuiControl, 2:, ED1, % productname
 GuiControl, 2:, ED2, % OSVersion.EasyVersion
 GuiControl, 2:, ED3, % OSVersion.ServicePackString
 GuiControl, 2:, ED4, % a_computername
 GuiControl, 2:, ED5, % a_username
 GuiControl, 2:, ED6, % a_ipaddress1
 GuiControl, 2:, ED7, % GMSExM01 MB

/*
	MsgBox % "ProductName`t:`t" . ProductName
		. "`nOS Version`t:`t" OSVersion.EasyVersion
		. "`nOS Service pack`t:`t" . OSVersion.ServicePackString
		. "`nComputer Name`t:`t" . a_computername
		. "`nUser Name`t:`t" . a_username
		. "`nIP Address`t`t:`t" . a_ipaddress1
		. "`nPhysical Memory`t:`t" . GMSExM01 MB
*/

; ***** FUNCTIONS *****
GetOSVersionInfo() {
        static Ver
	If !Ver
	{
		VarSetCapacity(OSVer, 284, 0)
		NumPut(284, OSVer, 0, "UInt")
		If !DllCall("GetVersionExW", "Ptr", &OSVer)
			return 0 ; GetSysErrorText(A_LastError)
		Ver := Object()
		Ver.MajorVersion      := NumGet(OSVer, 4, "UInt")
		Ver.MinorVersion      := NumGet(OSVer, 8, "UInt")
		Ver.BuildNumber       := NumGet(OSVer, 12, "UInt")
		Ver.PlatformId        := NumGet(OSVer, 16, "UInt")
		Ver.ServicePackString := StrGet(&OSVer+20, 128, "UTF-16")
		Ver.ServicePackMajor  := NumGet(OSVer, 276, "UShort")
		Ver.ServicePackMinor  := NumGet(OSVer, 278, "UShort")
		Ver.SuiteMask         := NumGet(OSVer, 280, "UShort")
		Ver.ProductType       := NumGet(OSVer, 282, "UChar")
		Ver.EasyVersion       := Ver.MajorVersion . "." . Ver.MinorVersion . "." . Ver.BuildNumber
	}
	return Ver
}
GlobalMemoryStatusEx() {
	static MEMORYSTATUSEX, init := VarSetCapacity(MEMORYSTATUSEX, 64, 0) && NumPut(64, MEMORYSTATUSEX, "UInt")
	if (DllCall("Kernel32.dll\GlobalMemoryStatusEx", "Ptr", &MEMORYSTATUSEX))
	{
		return { 2 : NumGet(MEMORYSTATUSEX, 8, "UInt64")
        , 3 : NumGet(MEMORYSTATUSEX, 16, "UInt64")
        , 4 : NumGet(MEMORYSTATUSEX, 24, "UInt64")
        , 5 : NumGet(MEMORYSTATUSEX, 32, "UInt64") }
	}
}
return
Rami
Posts: 55
Joined: 19 May 2016, 07:44

Re: Basic information about your computer

07 Nov 2016, 16:52

Thanx Garry, I really learned new things from your helps, will definitely use them.
Rami
Posts: 55
Joined: 19 May 2016, 07:44

Re: Basic information about your computer

08 Nov 2016, 16:53

Garry,
Any thought why do I get the WiFi password tens\hundreds characters?
Spoiler
User avatar
empardopo
Posts: 336
Joined: 06 Oct 2013, 12:50
Location: Spain
Contact:

Re: Basic information about your computer

09 Nov 2016, 03:51

Very nice. Maybe adding mac too would have been fine.
Thanks.
Everything is possible!
garry
Posts: 1885
Joined: 22 Dec 2013, 12:50

Re: Basic information about your computer

09 Nov 2016, 04:28

Rami , sorry I don't know
this is with a get with Windows10
check the xml-file ( which is created by netsh )

Code: Select all

setworkingdir,%a_scriptdir%
fd=%a_scriptdir%\WifiXMLS
ifnotexist,%fd%
  filecreatedir,%fd%
RunWait, %comspec% /c "netsh wlan export profile folder=%fd% key=clear",, hide
return

;netsh creates this file :
;     WiFi-athome99.xml

/*
<?xml version="1.0"?>
<WLANProfile xmlns="http://www.microsoft.com/networking/WLAN/profile/v1">
	<name>athome99</name>
	<SSIDConfig>
		<SSID>
			<hex>6174686F6D653332</hex>
			<name>athome99</name>
		</SSID>
	</SSIDConfig>
	<connectionType>ESS</connectionType>
	<connectionMode>auto</connectionMode>
	<MSM>
		<security>
			<authEncryption>
				<authentication>WPA2PSK</authentication>
				<encryption>AES</encryption>
				<useOneX>false</useOneX>
			</authEncryption>
			<sharedKey>
				<keyType>passPhrase</keyType>
				<protected>false</protected>
				<keyMaterial>athome9912345</keyMaterial>
			</sharedKey>
		</security>
	</MSM>
	<MacRandomization xmlns="http://www.microsoft.com/networking/WLAN/profile/v3">
		<enableRandomization>false</enableRandomization>
	</MacRandomization>
</WLANProfile>
*/
Rami
Posts: 55
Joined: 19 May 2016, 07:44

Re: Basic information about your computer

09 Nov 2016, 08:24

Garry, I checked it. I'm on Win 7, same long result
Thank you anyway.

empardopo,
here is how to add MAC address

Code: Select all

msgbox % GetMacAddress()

GetMacAddress(){
	Runwait, %ComSpec% /c getmac /NH | clip,,hide
	RegExMatch(clipboard, ".*?([0-9A-Z].{16})(?!\w\\Device)", mac)
	return %mac1%
}
Last edited by Rami on 09 Nov 2016, 09:14, edited 1 time in total.
Rami
Posts: 55
Joined: 19 May 2016, 07:44

Re: Basic information about your computer

09 Nov 2016, 09:07

Here is the final edition , i will not add more than these field on the top of my program, then the idea is to add buttons to run couple WMI Tasks
https://autohotkey.com/board/topic/6096 ... ith-ahk-l/
And include couple useful tools from SysInternal, and Nirsoft to run them from buttons also.

Here is the script right now if anyone is interested:

Code: Select all

#Persistent
#SingleInstance, force

SetWorkingDir, %A_ScriptDir%
SetBatchLines, -1

Gui,2:default
Gui,2:Font, s8 Bold cblack Arial
Gui,2:Add,Text , x8   y10   ,ProductName
Gui,2:Add,Text , x8   y40   ,OS Version
Gui,2:Add,Text , x8   y70   ,OS Service Pack
Gui,2:Add,Text , x250   y10  ,Computer Name
Gui,2:Add,Text , x250   y40  ,Username
Gui,2:Add,Text , x250   y70  ,Serial No.
Gui,2:Add,Text , x500   y10  ,IP Address
Gui,2:Add,Text , x500   y40  ,MAC Address
Gui,2:Add,Text , x500   y70  ,Domain

Gui,2:Font, s8 Norm Arial
Gui,2:Add,Edit , x110   y10  w120 h25 vED1  readonly,
Gui,2:Add,Edit , x110   y40  w120 h25 vED2  readonly,
Gui,2:Add,Edit , x110   y70  w120 h25 vED3  readonly,
Gui,2:Add,Edit , x355   y10  w120 h25 vED4  readonly,
Gui,2:Add,Edit , x355   y40  w120 h25 vED5  readonly,
Gui,2:Add,Edit , x355   y70  w120 h25 vED6  readonly,
Gui,2:Add,Edit , x600   y10  w120 h25 vED7  readonly,
Gui,2:Add,Edit , x600   y40  w120 h25 vED8  readonly,
Gui,2:Add,Edit , x600   y70  w120 h25 vED9  readonly,

Gui,2:show, x100 y10 w730 h500 ,Project1
Gui, Add, Picture, x0 y0 w730 h500 BackgroundTrans,%A_ScriptDir%\mybackground.bmp

gosub,EDs
return

2Guiclose:
exitapp

EDs:
RegRead, ProductName, HKEY_LOCAL_MACHINE, SOFTWARE\Microsoft\Windows NT\CurrentVersion, ProductName

If ( OSVersion := GetOSVersionInfo() )
	GuiControl, 2:, ED1, % productname
GuiControl, 2:, ED2, % OSVersion.EasyVersion
GuiControl, 2:, ED3, % OSVersion.ServicePackString
GuiControl, 2:, ED4, % a_computername
GuiControl, 2:, ED5, % a_username
gosub,ED6
GuiControl, 2:, ED7, % a_ipaddress1
GuiControl, 2:, ED8, % GetMacAddress()
gosub,ED9
GuiControl, 2:, ED9, % Domain 
return


ED6:
strComputer := "."
objWMIService := ComObjGet("winmgmts:{impersonationLevel=impersonate}!\\" . strComputer . "\root\cimv2")

colSettings := objWMIService.ExecQuery("Select * from Win32_BIOS")._NewEnum

While colSettings[objBiosItem]
{
	GuiControl, 2:, ED6, % objBiosItem.SerialNumber 
}
return

ED9:
EnvGet, Domain, USERDOMAIN
return

; ***** FUNCTIONS *****
GetOSVersionInfo() {
	static Ver
	If !Ver
	{
		VarSetCapacity(OSVer, 284, 0)
		NumPut(284, OSVer, 0, "UInt")
		If !DllCall("GetVersionExW", "Ptr", &OSVer)
			return 0 ; GetSysErrorText(A_LastError)
		Ver := Object()
		Ver.MajorVersion      := NumGet(OSVer, 4, "UInt")
		Ver.MinorVersion      := NumGet(OSVer, 8, "UInt")
		Ver.BuildNumber       := NumGet(OSVer, 12, "UInt")
		Ver.PlatformId        := NumGet(OSVer, 16, "UInt")
		Ver.ServicePackString := StrGet(&OSVer+20, 128, "UTF-16")
		Ver.ServicePackMajor  := NumGet(OSVer, 276, "UShort")
		Ver.ServicePackMinor  := NumGet(OSVer, 278, "UShort")
		Ver.SuiteMask         := NumGet(OSVer, 280, "UShort")
		Ver.ProductType       := NumGet(OSVer, 282, "UChar")
		Ver.EasyVersion       := Ver.MajorVersion . "." . Ver.MinorVersion . "." . Ver.BuildNumber
	}
	return Ver
}

GetMacAddress(){
	Runwait, %ComSpec% /c getmac /NH | clip,,hide
	RegExMatch(clipboard, ".*?([0-9A-Z].{16})(?!\w\\Device)", mac)
	return %mac1%
}

Return to “Ask For Help”

Who is online

Users browsing this forum: AHKStudent, CheshireCat, flyingDman, Gully and 75 guests