AutoHotkey Community

It is currently May 24th, 2012, 2:37 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 27 posts ]  Go to page Previous  1, 2
Author Message
 Post subject:
PostPosted: January 16th, 2007, 12:14 pm 
Offline
User avatar

Joined: December 26th, 2005, 4:40 pm
Posts: 8775
Here .. this seems to work:

Code:
VarSetCapacity(bGuid, 16,0)
VarSetCapacity(sGuid, 76)

dllcall("ole32.dll\CoCreateGuid", uint,  &bGuid)
x := dllcall("ole32.dll\StringFromGUID2", "uint", &bGuid, "str", sGuid, "int", 76)

Loop 76
 UUID .= (Mod(A_Index,2) = 1) ? Chr( *(&sGuid+(A_Index-1)) ) : ""

msgbox % UUID


:)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 16th, 2007, 12:33 pm 
Offline

Joined: December 27th, 2005, 1:46 pm
Posts: 6837
Location: France (near Paris)
Skan wrote:
I think Random command should be available as a function.
Most of such commands (with OutputVar) will become functions in v.2.

majkinetor: thanks for the research. Usable code:
Code:
VarSetCapacity(binGuid, 16) ; 128 bits
guidSize = 40   ; Slight oversize
VarSetCapacity(uniGuid, guidSize * 2)
DllCall("Ole32.dll\CoCreateGuid", "UInt", &binGuid)
bytes := DllCall("Ole32.dll\StringFromGUID2"
      , "UInt", &binGuid
      , "UInt", &uniGuid
      , "Int", guidSize * 2)
;~ MsgBox % DumpDWORDs(uniGuid, 80, true)
VarSetCapacity(ansiGuid, guidSize)
DllCall("WideCharToMultiByte"
      , "UInt", 0        ; CodePage: CP_ACP=0 (current Ansi), CP_UTF7=65000, CP_UTF8=65001
      , "UInt", 0        ; dwFlags
      , "UInt", &uniGuid ; LPCWSTR lpWideCharStr
      , "Int", guidSize  ; cchWideChar: size in WCHAR values, -1=null terminated
      , "Str", ansiGuid  ; LPSTR lpMultiByteStr
      , "Int", guidSize  ; cbMultiByte: 0 to get required size
      , "UInt", 0        ; LPCSTR lpDefaultChar
      , "UInt", 0)       ; LPBOOL lpUsedDefaultChar
MsgBox %bytes% %ansiGuid%

_________________
Image vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 16th, 2007, 12:53 pm 
Offline

Joined: May 24th, 2006, 2:49 pm
Posts: 4511
Location: Belgrade
This is the function:

Code:
msgbox % CreateGUID()

CreateGuid()
{
   local len, ansiString, data

   VarSetCapacity(data, 96)

   dllcall("ole32.dll\CoCreateGuid", "uint", &data)
   dllcall("ole32.dll\StringFromGUID2", "uint", &data, "str", data, "int", 40)

   len := DllCall("lstrlenW", "UInt", &data)
   VarSetCapacity(ansiString, len, 0)

   DllCall("WideCharToMultiByte"
         , "UInt", 0         ; CodePage: CP_ACP=0 (current Ansi), CP_UTF7=65000, CP_UTF8=65001
         , "UInt", 0         ; dwFlags
         , "UInt", &data      ; LPCWSTR lpWideCharStr
         , "Int", len         ; cchWideChar: size in WCHAR values, -1=null terminated
         , "Str", ansiString   ; LPSTR lpMultiByteStr
         , "Int", len         ; cbMultiByte: 0 to get required size
         , "UInt", 0         ; LPCSTR lpDefaultChar
         , "UInt", 0)         ; LPBOOL lpUsedDefaultChar

   Return ansiString
}


Ah... I went to lunch before posting this and I see that you already did this code. :D I modified Philhose GetAnsiStringFromUnicodePointer function ...

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 16th, 2007, 3:42 pm 
Offline

Joined: February 14th, 2005, 4:05 pm
Posts: 4710
Location: Boulder, CO
look here, too.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 16th, 2007, 4:07 pm 
Offline

Joined: May 24th, 2006, 2:49 pm
Posts: 4511
Location: Belgrade
thx

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 22nd, 2007, 12:06 am 
Offline

Joined: June 4th, 2005, 1:30 am
Posts: 113
Location: Stuttgart, Germany
Just for the record: Generate a GUID via COM (needs Sean's Standard Library COM.ahk)
Code:
CreateGUID()
{
  local pST, pGUID, sGUID
  COM_CoInitialize()
  pST := COM_ActiveXObject("Scriptlet.TypeLib")
  DllCall(COM_VTable(pST, 21), "Uint", pST, "UIntP", pGUID)
  COM_Unicode2Ansi(pGUID, sGUID)
  COM_SysFreeString(pGUID)
  COM_CoUninitialize()
  Return sGUID
}


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Why does this not work?
PostPosted: July 11th, 2009, 6:43 am 
Why does this not work?

Code:
^u::
;;msgbox % CreateGUID()
send % CreateGUID()
return

CreateGuid()
{
   local len, ansiString, data

   VarSetCapacity(data, 96)

   dllcall("ole32.dll\CoCreateGuid", "uint", &data)
   dllcall("ole32.dll\StringFromGUID2", "uint", &data, "str", data, "int", 40)

   len := DllCall("lstrlenW", "UInt", &data)
   VarSetCapacity(ansiString, len, 0)

   DllCall("WideCharToMultiByte"
         , "UInt", 0         ; CodePage: CP_ACP=0 (current Ansi), CP_UTF7=65000, CP_UTF8=65001
         , "UInt", 0         ; dwFlags
         , "UInt", &data      ; LPCWSTR lpWideCharStr
         , "Int", len         ; cchWideChar: size in WCHAR values, -1=null terminated
         , "Str", ansiString   ; LPSTR lpMultiByteStr
         , "Int", len         ; cbMultiByte: 0 to get required size
         , "UInt", 0         ; LPCSTR lpDefaultChar
         , "UInt", 0)         ; LPBOOL lpUsedDefaultChar

   Return ansiString
}




but this does work??


Code:
^u::
;;msgbox % CreateGUID()
send % CreateGUID()
return

CreateGuid()
{
   local len, ansiString, data

   VarSetCapacity(data, 96)

   dllcall("ole32.dll\CoCreateGuid", "uint", &data)
   dllcall("ole32.dll\StringFromGUID2", "uint", &data, "str", data, "int", 40)

   len := DllCall("lstrlenW", "UInt", &data)
   VarSetCapacity(ansiString, len, 0)

   DllCall("WideCharToMultiByte"
         , "UInt", 0         ; CodePage: CP_ACP=0 (current Ansi), CP_UTF7=65000, CP_UTF8=65001
         , "UInt", 0         ; dwFlags
         , "UInt", &data      ; LPCWSTR lpWideCharStr
         , "Int", len         ; cchWideChar: size in WCHAR values, -1=null terminated
         , "Str", ansiString   ; LPSTR lpMultiByteStr
         , "Int", len         ; cbMultiByte: 0 to get required size
         , "UInt", 0         ; LPCSTR lpDefaultChar
         , "UInt", 0)         ; LPBOOL lpUsedDefaultChar

   Return ansiString
}



I'm smashing my face on the screen here with frustration.....


Report this post
Top
  
Reply with quote  
 Post subject: frell
PostPosted: July 11th, 2009, 6:44 am 
i posted the same thing twice...

there was a very minute change i didn't paste in cause i was fumeing mad...



here is the one that works:

^u::
msgbox % CreateGUID()
;;send % CreateGUID()
return

CreateGuid()
{
local len, ansiString, data

VarSetCapacity(data, 96)

dllcall("ole32.dll\CoCreateGuid", "uint", &data)
dllcall("ole32.dll\StringFromGUID2", "uint", &data, "str", data, "int", 40)

len := DllCall("lstrlenW", "UInt", &data)
VarSetCapacity(ansiString, len, 0)

DllCall("WideCharToMultiByte"
, "UInt", 0 ; CodePage: CP_ACP=0 (current Ansi), CP_UTF7=65000, CP_UTF8=65001
, "UInt", 0 ; dwFlags
, "UInt", &data ; LPCWSTR lpWideCharStr
, "Int", len ; cchWideChar: size in WCHAR values, -1=null terminated
, "Str", ansiString ; LPSTR lpMultiByteStr
, "Int", len ; cbMultiByte: 0 to get required size
, "UInt", 0 ; LPCSTR lpDefaultChar
, "UInt", 0) ; LPBOOL lpUsedDefaultChar

Return ansiString
}


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: July 11th, 2009, 6:49 am 
so why does the send version of this not work?
while the useless msgbox version does?

the only difference is?


whats so preposterously different with MSGBOX that SEND cant do similar things???

i don't want a MSGBOX with a UUID cause i have to punch my screen in trying to copy the number and letter string item for item character for character...

damnit this is really pissing me off. i shouldn't have to come to the forum for help on this. it's the most basic part of autohotkey. Send should be second nature to me by now damnit.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: July 11th, 2009, 6:55 am 
I'm sitting here scanning through help file and index after bloody index, with no examples of how to call a function from a SEND, but of course MSGBOX can do it. no problem... WHY? i spent 3 hours trying to run experiments and read through that felling help file. I looked in the forum, but of course i have to shovel through billions of posts and read 9k pages of stuff that has nothing to do with my problem only to end up here finally posting... because SEND for some magically delicious reason behaves nothing like MSGBOX. it's moments like these where i realize college courses spent on computer programing are an epic waste of money. Damnit!


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: July 11th, 2009, 7:22 am 
35 experiments later,

i find that i was finally able to make it work with SENDRAW

Good it's done.. now i'm crawling into bed.

side effect of Flu = Very very angry Rabbit...

Ò¬Ó


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: February 20th, 2011, 11:25 am 
Offline

Joined: November 7th, 2006, 9:47 pm
Posts: 1933
Location: Germany
Just a small hint: AHK_L says unsupported use of ".". There should be space after SubStr(), then it works. Spcifically change line
Code:
x := 9 . SubStr(x, 3) . s . 1 . SubStr(y, 3). SubStr(z, 3)

to
Code:
x := 9 . SubStr(x, 3) . s . 1 . SubStr(y, 3) . SubStr(z, 3)

_________________
{1:"ahkstdlib", 2:"my libs", 3:"my apps", 4:"my license"}
--> Don't feed the troll! <--


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 27 posts ]  Go to page Previous  1, 2

All times are UTC [ DST ]


Who is online

Users browsing this forum: Exabot [Bot], xXDarknessXx and 26 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group