I think I got the latest ones...
Running on W7/64-bit with v1.1.32.00/U64, if that matters. The test script that I'm using is below. It creates the shortcut with everything set properly...except for the shortcut key...that displays in the shortcut's Properties as
. Regards, Joe
Code: Select all
vTarget:="c:\temp\test jeeswg.txt"
vPathLink:=A_Desktop . "\test jeeswg link " . A_Now . ".lnk"
vWorkingDir:=A_ScriptDir
vArgs:="a b c"
vDescription:="shortcut description"
vIconFile:=A_AhkPath
vShortcutKey:="^!+q"
vIconNum:=4
vRunState:=1
JEE_FileCreateShortcut(vTarget,vPathLink,vWorkingDir,vArgs,vDescription,vIconFile,vShortcutKey,vIconNum,vRunState)
MsgBox,4096,Create Done,%vPathLink%
ExitApp
JEE_FileCreateShortcut(vTarget, vPathLink, vWorkingDir:="", vArgs:="", vDescription:="", vIconFile:="", vShortcutKey:="", vIconNum:=0, vRunState:="")
{
local
static IID_IShellLinkW := "{000214F9-0000-0000-C000-000000000046}"
static CLSID_ShellLink := "{00021401-0000-0000-C000-000000000046}"
static IID_IPersistFile := "{0000010b-0000-0000-C000-000000000046}"
if !(pSL := ComObjCreate(CLSID_ShellLink, IID_IShellLinkW))
return 0
;set Target
;SLGP_RAWPATH := 0x4 ;SLGP_UNCPRIORITY := 0x2 ;SLGP_SHORTPATH := 0x1 ;source: ShObjIdl.h
if DllCall(NumGet(NumGet(pSL+0) + 20*A_PtrSize), "Ptr",pSL, "WStr",vTarget) ;IShellLink::SetPath
return 0
;set WorkingDir
if !(vWorkingDir = "")
&& DllCall(NumGet(NumGet(pSL+0) + 9*A_PtrSize), "Ptr",pSL, "WStr",vWorkingDir) ;IShellLink::SetWorkingDirectory
return 0
;set Args
if !(vArgs = "")
&& DllCall(NumGet(NumGet(pSL+0) + 11*A_PtrSize), "Ptr",pSL, "WStr",vArgs) ;IShellLink::SetArguments
return 0
;set Description
if !(vDescription = "")
&& DllCall(NumGet(NumGet(pSL+0) + 7*A_PtrSize), "Ptr",pSL, "WStr",vDescription) ;IShellLink::SetDescription
return 0
;set IconFile and IconNum
if !(vIconFile = "")
&& DllCall(NumGet(NumGet(pSL+0) + 17*A_PtrSize), "Ptr",pSL, "WStr",vIconFile, "Int",vIconNum) ;IShellLink::SetIconLocation
return 0
if !(vShortcutKey = "")
{
vHotkeyNum := 0
if RegExMatch(vShortcutKey, "^.?\+.")
{
vHotkeyNum |= (0x1 << 8) ;HOTKEYF_SHIFT := 0x1
vShortcutKey := StrReplace(vShortcutKey, "+", "",, 1)
}
if RegExMatch(vShortcutKey, "^.?\^.")
{
vHotkeyNum |= (0x2 << 8) ;HOTKEYF_CONTROL := 0x2
vShortcutKey := StrReplace(vShortcutKey, "^", "",, 1)
}
if RegExMatch(vShortcutKey, "^.?!.")
{
vHotkeyNum |= (0x4 << 8) ;HOTKEYF_ALT := 0x4
vShortcutKey := StrReplace(vShortcutKey, "!", "",, 1)
}
if vVK := GetKeyVK(vShortcutKey)
vHotkeyNum |= vVK
if vVK
&& DllCall(NumGet(NumGet(pSL+0) + 13*A_PtrSize), "Ptr",pSL, "UShort",vHotkeyNum) ;IShellLink::SetHotkey
return 0
}
if !(vRunState = "")
&& DllCall(NumGet(NumGet(pSL+0) + 15*A_PtrSize), "Ptr",pSL, "Int",vRunState) ;IShellLink::SetShowCmd
return 0
if !(pPF := ComObjQuery(pSL, IID_IPersistFile))
return 0
vSize := DllCall("kernel32\GetFullPathNameW", "WStr","\\?\" vPathLink, "UInt",0, "Ptr",0, "Ptr*",0, "UInt")
VarSetCapacity(vPath2, vSize*2, 0)
if !DllCall("kernel32\GetFullPathNameW", "WStr","\\?\" vPathLink, "UInt",vSize, "Ptr",&vPath2, "Ptr*",0, "UInt")
return 0
if DllCall(NumGet(NumGet(pPF+0) + 6*A_PtrSize), "Ptr",pPF, "Ptr",&vPath2, "Int",1) ;IPersistFile::Save
return 0
ObjRelease(pPF)
ObjRelease(pSL)
return 1
}