To Share: Simple GUID (Globally Unique IDentifier) Generator

Post your working scripts, libraries and tools
Nagendra
Posts: 14
Joined: 25 May 2017, 02:23

To Share: Simple GUID (Globally Unique IDentifier) Generator

24 Oct 2017, 02:36

Hi,

Here is the simple script to generate GUIDs.

Code: Select all

shellobj := ComObjCreate("Scriptlet.TypeLib")
shellexec := shellobj.GUID
clipboard := shellexec
MsgBox, % clipboard
ExitApp
User avatar
jeeswg
Posts: 6469
Joined: 19 Dec 2016, 01:58
Location: UK

Re: To Share: Simple GUID (Globally Unique IDentifier) Generator

24 Oct 2017, 17:50

Wow, so simple. Thanks for sharing.

A great response to this:
ObjRegisterActive - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=6&t=6148

Code: Select all

; Register our object so that other scripts can get to it.  The second
; parameter is a GUID which I generated.  You should generate one unique
; to your script.  You can use [CreateGUID](http://goo.gl/obfmDc).
ObjRegisterActive(ActiveObject, "{6B39CAA1-A320-4CB0-8DB4-352AA81E460E}")
And this:
GUID & UUID - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=6&t=4732
Spoiler
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
Nagendra
Posts: 14
Joined: 25 May 2017, 02:23

Re: To Share: Simple GUID (Globally Unique IDentifier) Generator

26 Oct 2017, 13:47

This script creates a unique GUID by searching in the Registry.

Code: Select all

StartTime := A_TickCount
FileDelete, %A_Temp%\TempReg.reg
RunWait, %A_WinDir%\Regedit.exe /E %A_Temp%\TempReg.reg
FileRead, RegistryContents, %A_Temp%\TempReg.reg
Start:
NewGUID := ComObjCreate("Scriptlet.TypeLib").GUID
IfInString, RegistryContents, %NewGUID%
	Goto Start
clipboard := NewGUID
ElapsedTime := A_TickCount - StartTime
ElapsedTime := ElapsedTime /1000
MsgBox, % clipboard "`n Time Taken in Seconds: " ElapsedTime
Nagendra
Posts: 14
Joined: 25 May 2017, 02:23

Re: To Share: Simple GUID (Globally Unique IDentifier) Generator

26 Oct 2017, 13:50

For creating a unique GUID number, it's one liner script

Code: Select all

clipboard := ComObjCreate("Scriptlet.TypeLib").GUID
MsgBox, % clipboard
Helgef
Posts: 3778
Joined: 17 Jul 2016, 01:02
Contact:

Re: To Share: Simple GUID (Globally Unique IDentifier) Generator

29 Oct 2017, 08:38

Thanks for sharing Nagendra. :wave:
jeeswg wrote:But how can we be sure that the GUID is unique!?

Code: Select all

shellobj := ComObjCreate("Scriptlet.TypeLib")
shellexec := shellobj.GUID
To me it looks like the GUID is meant to uniquely identify the the created object, if so, by definition, it is not going to uniquely identify anything else, no matter if it is unique or not. ;)

Cheers.

Return to “Scripts and Functions”

Who is online

Users browsing this forum: Argimko and 36 guests