 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
SKAN
Joined: 26 Dec 2005 Posts: 8688
|
Posted: Tue Jan 16, 2007 11:14 am Post subject: |
|
|
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 |
 |
|
| Back to top |
|
 |
PhiLho
Joined: 27 Dec 2005 Posts: 6836 Location: France (near Paris)
|
Posted: Tue Jan 16, 2007 11:33 am Post subject: |
|
|
| 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%
|
_________________
vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2") |
|
| Back to top |
|
 |
majkinetor
Joined: 24 May 2006 Posts: 4511 Location: Belgrade
|
Posted: Tue Jan 16, 2007 11:53 am Post subject: |
|
|
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. I modified Philhose GetAnsiStringFromUnicodePointer function ... _________________
 |
|
| Back to top |
|
 |
Laszlo
Joined: 14 Feb 2005 Posts: 4710 Location: Boulder, CO
|
Posted: Tue Jan 16, 2007 2:42 pm Post subject: |
|
|
| look here, too. |
|
| Back to top |
|
 |
majkinetor
Joined: 24 May 2006 Posts: 4511 Location: Belgrade
|
Posted: Tue Jan 16, 2007 3:07 pm Post subject: |
|
|
thx _________________
 |
|
| Back to top |
|
 |
olfen
Joined: 04 Jun 2005 Posts: 113 Location: Stuttgart, Germany
|
Posted: Fri Sep 21, 2007 11:06 pm Post subject: |
|
|
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
} |
|
|
| Back to top |
|
 |
ThumpieBunnyEve Guest
|
Posted: Sat Jul 11, 2009 5:43 am Post subject: Why does this not work? |
|
|
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..... |
|
| Back to top |
|
 |
ThumpieBunnyEve Guest
|
Posted: Sat Jul 11, 2009 5:44 am Post subject: frell |
|
|
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
} |
|
| Back to top |
|
 |
ThumpieBunnyEve Guest
|
Posted: Sat Jul 11, 2009 5:49 am Post subject: |
|
|
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. |
|
| Back to top |
|
 |
ThumpieBunnyEve Guest
|
Posted: Sat Jul 11, 2009 5:55 am Post subject: |
|
|
| 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! |
|
| Back to top |
|
 |
ThumpieBunnyEve Guest
|
Posted: Sat Jul 11, 2009 6:22 am Post subject: |
|
|
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...
Ò¬Ó |
|
| Back to top |
|
 |
Tuncay
Joined: 07 Nov 2006 Posts: 1886 Location: Germany
|
Posted: Sun Feb 20, 2011 10:25 am Post subject: |
|
|
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! <-- |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|