| 
					 
							
													 
							
						 
						
 
 | 
 | 
 
2013/7/23(Tue) 20:03:20|NO.55843 
 |   
  
 
 | 
 | 
 
2013/7/24(Wed) 09:03:10|NO.55850 
多分[送信]ボタンを2回押したか何かで同じ内容のスレが2つ建ってしまっているので、 
もう1つのスレのほうを削除してください。 
このスレを削除すると、私が既に書き込んでいるため、質問内容は消えるものの、スレ自体のページが残ってしまいます。 
 
 |   
  
| 
 | 
 
2013/7/24(Wed) 09:37:35|NO.55855 
これはWindowsがもつCOMの機能を使用しているので、HSPのcom関連の命令を用いるとできます。 
と思ってやってみたのですが、なぜだかジャンプリストがうまくできません。誰か分かる人いないでしょうか。
  
#uselib "ole32.dll"
#cfunc CoTaskMemAlloc "CoTaskMemAlloc" int
#func CoTaskMemFree "CoTaskMemFree" sptr
#define CLSID_DestinationList            "{77F10CF0-3DB5-4966-B520-B7C54FD35ED6}"
#define CLSID_ShellLink                  "{00021401-0000-0000-C000-000000000046}"
#define CLSID_EnumerableObjectCollection "{2D3468C1-36A7-43B6-AC24-D3F02FD9607A}"
#define IID_ICustomDestinationlist       "{6332DEBF-87B5-4670-90C0-5E57B408A49E}"
#define IID_IShellLink                   "{000214EE-0000-0000-C000-000000000046}"
#define IID_IObjectCollection            "{5632B1A4-E38A-400A-928A-D4CD63230295}"
#define IID_IObjectArray                 "{92CA9DCD-5622-4BBA-A805-5E9F541BD8C9}"
#define IID_IPropertyStore               "{886D8EEB-8CF2-4446-8D02-CDBA1DBDCf99}"
#usecom ICustomDestinationlist IID_ICustomDestinationlist CLSID_DestinationList
#comfunc ICustomDestinationlist_BeginList 4 int,int,int
#comfunc ICustomDestinationlist_AddUserTasks 7 int
#comfunc ICustomDestinationlist_CommitList 8
#usecom IShellLink IID_IShellLink CLSID_ShellLink
#comfunc IShellLink_QueryInterface 0 int,int
#comfunc IShellLink_SetArguments 11 str
#comfunc IShellLink_SetIconLocation 17 str,int
#comfunc IShellLink_SetPath 20 str
#usecom IObjectCollection IID_IObjectCollection CLSID_EnumerableObjectCollection
#comfunc IObjectCollection_QueryInterface 0 int,int
#comfunc IObjectCollection_GetCount 3 int
#comfunc IObjectCollection_AddObject 5 int
#usecom IObjectArray IID_IObjectArray
#comfunc IObjectArray_Releace 2
#comfunc IObjectArray_GetCount 3 int
#usecom IPropertyStore IID_IPropertyStore
#comfunc IPropertyStore_QueryInterface 0 int,int
#comfunc IPropertyStore_SetValue 6 int,int
#comfunc IPropertyStore_Commit 7
// ICustomDestinationlistのCOMオブジェクトを初期化
newcom list,ICustomDestinationList
//GUID構造体(IID_IObjectArray)
dim GUID,4
//{92CA9DCD-5622-4BBA-A805-5E9F541BD8C9}
//lpoke GUID,0,0x92CA9DCD
lpoke GUID,0,0xCD9DCA92
wpoke GUID,4,0x2256
wpoke GUID,6,0xBA4B
lpoke GUID,8,0x9F5E05A8
lpoke GUID,12,0xC9D81B54
//ジャンプリストを作成開始する
ptr=0:ptr2=0
ICustomDestinationlist_BeginList list,varptr(ptr),varptr(GUID),varptr(ptr2)
mes ptr
mes ptr2	//なんで0なのか?
//IObjectArrayはいらないので解放する
//newcom objarr,IObjectArray,-1,ptr2
//IObjectArray_Releace objarr
//IObjectCollectionのCOMオブジェクトを初期化
newcom objcollection,IObjectCollection
//ジャンプリストの項目(ShellLink)を作る
newcom task,IShellLink
//とりあえず自分を指す
IShellLink_SetPath task,dirinfo(1)+"\\hsp3.exe"	
//実行時引数
IShellLink_SetArguments task,""
//アイコン
IShellLink_SetIconLocation task,dirinfo(1)+"\\hsp3.exe"	,0
//項目名をいじるためにIPropertyStoreを取得
querycom pstore, task, IPropertyStore
//PROPERTYKEY構造体を作る PKEY_Title:{F29F85E0-4FF9-1068-AB91-08002B27B3D9} 2
dim PROPERTYKEY,5
lpoke PROPERTYKEY,0,0xE0859FF2
lpoke PROPERTYKEY,4,0x6810F94F
lpoke PROPERTYKEY,8,0x000891AB
lpoke PROPERTYKEY,12,0xD9B3272B
lpoke PROPERTYKEY,16,0x00000002
//値を渡すためにPROPVARIANT構造体を作る
dim PROPVARIANT,4
//COM用に領域を確保する
ptr=CoTaskMemAlloc(256)
dupptr titlestr,ptr,256
//ポインタ用に入れる
poke titlestr,0,"タスク"
poke titlestr,7,0
PROPVARIANT(0)=30	//VT_LPSTR
lpoke PROPVARIANT,8,ptr
//値を入れる
IPropertyStore_SetValue pstore,varptr(PROPERTYKEY),varptr(PROPVARIANT)
//変更を保存する
IPropertyStore_Commit pstore
//メモリ領域解放
CoTaskMemFree ptr
//IObjectCollectionにタスクを追加する
dupptr ptr,varptr(task),4	//実はcom変数の実体はポインタのポインタ
ptr2=0
IObjectCollection_GetCount objcollection,varptr(ptr2)
mes ptr2
IObjectCollection_AddObject objcollection,ptr
IObjectCollection_GetCount objcollection,varptr(ptr2)
mes ptr2
//IObjectCollectionからIObjectArrayを求める 
querycom objarr, objcollection, IObjectArray
dupptr ptr,varptr(objarr),4	//IObjectArray*
IObjectArray_GetCount objarr,varptr(ptr2)
mes ptr2
//ICustomDestinationに追加する
ICustomDestinationlist_AddUserTasks list,ptr
//変更を反映する
ICustomDestinationlist_CommitList list
//後始末
delcom pstore
delcom task
delcom objarr
delcom objcollection
delcom list
</rpe>
  
 
  |    |   
  
| 
 | 
 
2013/7/24(Wed) 11:26:42|NO.55857 
GUID? 
 
lpoke GUID,0,0xCD9DCA92
wpoke GUID,4,0x2256
wpoke GUID,6,0xBA4B
 
↓
  
lpoke GUID,0,0x92CA9DCD
wpoke GUID,4,0x5622
wpoke GUID,6,0x4BBA
 
http://codetter.com/?p=390
 
 |   
  
| 
 | 
 
2013/7/24(Wed) 16:09:46|NO.55858 
ご指摘ありがとうございます。それと、PROPERTYKEY構造体が原因でした。 
あとでモジュール化してみようと思います。
 
以下のサンプルは実行ファイル作成してから実行して下さい(スクリプトエディタ上だとStartup Failedが出るため)。 
このサンプルは、実はほとんど  http://code.msdn.microsoft.com/windowsdesktop/VisualC-7741bc8e をHSPに移植しただけです。
  
#uselib "ole32.dll"
#cfunc CoTaskMemAlloc "CoTaskMemAlloc" int
#func CoTaskMemFree "CoTaskMemFree" sptr
#define CLSID_DestinationList            "{77F10CF0-3DB5-4966-B520-B7C54FD35ED6}"
#define CLSID_ShellLink                  "{00021401-0000-0000-C000-000000000046}"
#define CLSID_EnumerableObjectCollection "{2D3468C1-36A7-43B6-AC24-D3F02FD9607A}"
#define IID_ICustomDestinationlist       "{6332DEBF-87B5-4670-90C0-5E57B408A49E}"
#define IID_IShellLink                   "{000214EE-0000-0000-C000-000000000046}"
#define IID_IObjectCollection            "{5632B1A4-E38A-400A-928A-D4CD63230295}"
#define IID_IObjectArray                 "{92CA9DCD-5622-4BBA-A805-5E9F541BD8C9}"
#define IID_IPropertyStore               "{886D8EEB-8CF2-4446-8D02-CDBA1DBDCf99}"
#usecom ICustomDestinationlist IID_ICustomDestinationlist CLSID_DestinationList
#comfunc ICustomDestinationlist_BeginList 4 int,int,int
#comfunc ICustomDestinationlist_AddUserTasks 7 int
#comfunc ICustomDestinationlist_CommitList 8
#usecom IShellLink IID_IShellLink CLSID_ShellLink
#comfunc IShellLink_QueryInterface 0 int,int
#comfunc IShellLink_SetArguments 11 str
#comfunc IShellLink_SetIconLocation 17 str,int
#comfunc IShellLink_SetPath 20 str
#usecom IObjectCollection IID_IObjectCollection CLSID_EnumerableObjectCollection
#comfunc IObjectCollection_QueryInterface 0 int,int
#comfunc IObjectCollection_GetCount 3 int
#comfunc IObjectCollection_AddObject 5 int
#usecom IObjectArray IID_IObjectArray
#comfunc IObjectArray_Releace 2
#comfunc IObjectArray_GetCount 3 int
#usecom IPropertyStore IID_IPropertyStore
#comfunc IPropertyStore_QueryInterface 0 int,int
#comfunc IPropertyStore_SetValue 6 int,int
#comfunc IPropertyStore_Commit 7
// ICustomDestinationlistのCOMオブジェクトを初期化
newcom list,ICustomDestinationList
//GUID構造体(IID_IObjectArray)
dim GUID,4
//{92CA9DCD-5622-4BBA-A805-5E9F541BD8C9}
lpoke GUID,0,0x92CA9DCD
wpoke GUID,4,0x5622
wpoke GUID,6,0x4BBA
lpoke GUID,8,0x9F5E05A8
lpoke GUID,12,0xC9D81B54
//ジャンプリストを作成開始する
ptr=0:ptr2=0
ICustomDestinationlist_BeginList list,varptr(ptr),varptr(GUID),varptr(ptr2)
mes dirinfo(4)
mes ptr
mes ptr2	//なんで0なのか?
//IObjectArrayはいらないので解放する
//newcom objarr,IObjectArray,-1,ptr2
//IObjectArray_Releace objarr
//IObjectCollectionのCOMオブジェクトを初期化
newcom objcollection,IObjectCollection
//ジャンプリストの項目(ShellLink)を作る
newcom task,IShellLink
//とりあえず自分を指す
mes dirinfo(1)+"\\hsptmp.exe"	
IShellLink_SetPath task,dirinfo(1)+"\\hsptmp.exe"	
//実行時引数
IShellLink_SetArguments task,""
//アイコン
IShellLink_SetIconLocation task,dirinfo(1)+"\\hsptmp.exe"	,0
//項目名をいじるためにIPropertyStoreを取得
querycom pstore, task, IPropertyStore
//PROPERTYKEY構造体を作る PKEY_Title:{F29F85E0-4FF9-1068-AB91-08002B27B3D9} 2
dim PROPERTYKEY,5
lpoke PROPERTYKEY,0,0xF29f85E0
wpoke PROPERTYKEY,4,0x4FF9
wpoke PROPERTYKEY,6,0x1068
lpoke PROPERTYKEY,8,0x000891AB
lpoke PROPERTYKEY,12,0xD9B3272B
lpoke PROPERTYKEY,16,0x00000002
//値を渡すためにPROPVARIANT構造体を作る
dim PROPVARIANT,4
//COM用に領域を確保する
ptr=CoTaskMemAlloc(256)
dupptr titlestr,ptr,256
//ポインタ用に入れる
poke titlestr,0,"タスク"
poke titlestr,7,0
PROPVARIANT(0)=30	//VT_LPSTR
lpoke PROPVARIANT,8,ptr
//値を入れる
IPropertyStore_SetValue pstore,varptr(PROPERTYKEY),varptr(PROPVARIANT)
//変更を保存する
IPropertyStore_Commit pstore
//メモリ領域解放
CoTaskMemFree ptr
//IObjectCollectionにタスクを追加する
dupptr ptr,varptr(task),4	//実はcom変数の実体はポインタのポインタ
ptr2=0
IObjectCollection_GetCount objcollection,varptr(ptr2)
mes ptr2
IObjectCollection_AddObject objcollection,ptr
IObjectCollection_GetCount objcollection,varptr(ptr2)
mes ptr2
//IObjectCollectionからIObjectArrayを求める 
querycom objarr, objcollection, IObjectArray
dupptr ptr,varptr(objarr),4	//IObjectArray*
IObjectArray_GetCount objarr,varptr(ptr2)
mes ptr2
//ICustomDestinationに追加する
ICustomDestinationlist_AddUserTasks list,ptr
//変更を反映する
ICustomDestinationlist_CommitList list
//後始末
delcom pstore
delcom task
delcom objarr
delcom objcollection
delcom list
 
 
 
  |    |   
  
| 
 | 
 
2013/7/24(Wed) 17:44:33|NO.55861 
モジュール化しました。 
 
#module
#uselib "ole32.dll"
#cfunc CoTaskMemAlloc "CoTaskMemAlloc" int
#func CoTaskMemFree "CoTaskMemFree" sptr
#uselib "kernel32.dll"
#func GetModuleFileName "GetModuleFileNameA" int,int,int
#define CLSID_DestinationList            "{77F10CF0-3DB5-4966-B520-B7C54FD35ED6}"
#define CLSID_ShellLink                  "{00021401-0000-0000-C000-000000000046}"
#define CLSID_EnumerableObjectCollection "{2D3468C1-36A7-43B6-AC24-D3F02FD9607A}"
#define IID_ICustomDestinationlist       "{6332DEBF-87B5-4670-90C0-5E57B408A49E}"
#define IID_IShellLink                   "{000214EE-0000-0000-C000-000000000046}"
#define IID_IObjectCollection            "{5632B1A4-E38A-400A-928A-D4CD63230295}"
#define IID_IObjectArray                 "{92CA9DCD-5622-4BBA-A805-5E9F541BD8C9}"
#define IID_IPropertyStore               "{886D8EEB-8CF2-4446-8D02-CDBA1DBDCf99}"
#usecom ICustomDestinationlist IID_ICustomDestinationlist CLSID_DestinationList
#comfunc ICustomDestinationlist_BeginList 4 int,int,int
#comfunc ICustomDestinationlist_AppendCategory 5 wstr,int
#comfunc ICustomDestinationlist_AddUserTasks 7 int
#comfunc ICustomDestinationlist_CommitList 8
#usecom IShellLink IID_IShellLink CLSID_ShellLink
#comfunc IShellLink_QueryInterface 0 int,int
#comfunc IShellLink_SetArguments 11 str
#comfunc IShellLink_SetHotkey 13 int
#comfunc IShellLink_SetIconLocation 17 str,int
#comfunc IShellLink_SetPath 20 str
#usecom IObjectCollection IID_IObjectCollection CLSID_EnumerableObjectCollection
#comfunc IObjectCollection_QueryInterface 0 int,int
#comfunc IObjectCollection_GetCount 3 int
#comfunc IObjectCollection_AddObject 5 int
#usecom IObjectArray IID_IObjectArray
#comfunc IObjectArray_Releace 2
#comfunc IObjectArray_GetCount 3 int
#usecom IPropertyStore IID_IPropertyStore
#comfunc IPropertyStore_QueryInterface 0 int,int
#comfunc IPropertyStore_SetValue 6 int,int
#comfunc IPropertyStore_Commit 7
//GLOBAL: destlist,categories,task_category
//同時に処理可能?
#define MAX_CATEGORY 5
//自分のファイル名
#defcfunc getMyFilename local buf
	sdim buf,260
	GetModuleFileName 0,varptr(buf),260
	return buf
// ジャンプリスト初期化命令(使用可能にする)
#deffunc beginJumpList local GUID,local ptr,local ptr2
	newcom destlist,ICustomDestinationList
	//GUID構造体(IID_IObjectArray)
	dim GUID,4
	//{92CA9DCD-5622-4BBA-A805-5E9F541BD8C9}
	
	lpoke GUID,0,0x92CA9DCD
	wpoke GUID,4,0x5622
	wpoke GUID,6,0x4BBA
	lpoke GUID,8,0x9F5E05A8
	lpoke GUID,12,0xC9D81B54	
	
	//ジャンプリストを作成開始する
	ptr=0:ptr2=0
	ICustomDestinationlist_BeginList destlist,varptr(ptr),varptr(GUID),varptr(ptr2)
	
	//グローバル変数
	dimtype categories,6,MAX_CATEGORY	//COM配列(IObjectCollectionを入れる)
	sdim categorynames,256,MAX_CATEGORY
	//タスク用
	newcom task_category,IObjectCollection
	return
//ジャンプリスト反映命令(最後に必要)
#deffunc commitJumpList local objarr,local ptr
	//まずタスクを反映
	querycom objarr, task_category, IObjectArray
	
	dupptr ptr,varptr(objarr),4	//IObjectArray*
	
	//ICustomDestinationに追加する
	ICustomDestinationlist_AddUserTasks destlist,ptr
	
	//変更を反映する
	ICustomDestinationlist_CommitList destlist
	
	delcom destlist
	return
	
//カテゴリを作る
//引数:カテゴリ名 stat:カテゴリID
#deffunc makeCategory str name,local index
	//新しく作成するCOMのindexを探す
	index=0
	foreach categories
		if varuse(categories(index))==0{
			//未使用
			break
		}
		index++
	loop
	
	newcom categories(index),IObjectCollection
	categorynames(index)=name
	
	return
//カテゴリをリストに追加する
#deffunc commitCategory int catid,local objarr,local ptr
	//まずタスクを反映
	querycom objarr, categories(catid), IObjectArray
	
	dupptr ptr,varptr(objarr),4	//IObjectArray*
	
	//ICustomDestinationに追加する
	ICustomDestinationlist_AppendCategory destlist,categorynames(index),ptr
	
	delcom categories(catid)
	return
	
//カテゴリに新しいシェルリンクを追加
//catid:カテゴリID name:表示名 path:実行ファイルのパス arguments:引数 icon:アイコンファイルのパス iconid:アイコンのID
#deffunc addNewShellLink int catid,str name,str path,str arguments,str icon,int iconid,local shelllink,local pstore,local ptr,local titlestr,local PROPERTYKEY,local PROPVARIANT
	newcom shelllink,IShellLink
	
	IShellLink_SetPath shelllink,path
	IShellLink_SetArguments shelllink,arguments
	IShellLink_SetIconLocation shelllink,icon,iconid
	querycom pstore, shelllink, IPropertyStore
	//PKEY_Title:{F29F85E0-4FF9-1068-AB91-08002B27B3D9} 2
	dim PROPERTYKEY,5
	lpoke PROPERTYKEY,0,0xF29f85E0
	wpoke PROPERTYKEY,4,0x4FF9
	wpoke PROPERTYKEY,6,0x1068
	lpoke PROPERTYKEY,8,0x000891AB
	lpoke PROPERTYKEY,12,0xD9B3272B
	lpoke PROPERTYKEY,16,0x00000002
	dim PROPVARIANT,4
	ptr=CoTaskMemAlloc(256)
	dupptr titlestr,ptr,256
	//ポインタ用に入れる
	poke titlestr,0,name
	poke titlestr,strlen(name),0
	
	
	PROPVARIANT(0)=30	//VT_LPSTR
	lpoke PROPVARIANT,8,ptr
	
	//値を入れる
	IPropertyStore_SetValue pstore,varptr(PROPERTYKEY),varptr(PROPVARIANT)
	//変更を保存する
	IPropertyStore_Commit pstore
	
	delcom pstore
	CoTaskMemFree ptr
	
	//IObjectArrayに追加する
	dupptr ptr,varptr(shelllink),4	//IShellLinkへのポインタ
	
	if catid==-1{
		//タスクに追加
		IObjectCollection_AddObject task_category,ptr
	}else{
		IObjectCollection_AddObject categories(catid),ptr
	}
	delcom shelllink
	return
	
//カテゴリにセパレータ(なぜか使用不可)
/*
//catid:カテゴリID
#deffunc addSeparator int catid,local shelllink,local pstore,local ptr,local PROPERTYKEY,local PROPVARIANT
	newcom shelllink,IShellLink
	querycom pstore, shelllink, IPropertyStore
	//PKEY_AppUserModel_IsDestListSeparator {9F4C2855-9F79-4B39-A8D0-E1D42DE1D5F3} 6
	dim PROPERTYKEY,5
	lpoke PROPERTYKEY,0,0x9F4C2855
	wpoke PROPERTYKEY,4,0x9F79
	wpoke PROPERTYKEY,6,0x4B39
	lpoke PROPERTYKEY,8,D4E1D0A8
	lpoke PROPERTYKEY,12,0xF3D5E12D
	lpoke PROPERTYKEY,16,0x00000006
	dim PROPVARIANT,3
	
	PROPVARIANT(0)=11	//VT_BOOL
	wpoke PROPVARIANT,8,0xFFFF	//true
	
	//値を入れる
	IPropertyStore_SetValue pstore,varptr(PROPERTYKEY),varptr(PROPVARIANT)
	//変更を保存する
	IPropertyStore_Commit pstore
	
	delcom pstore
	
	//IObjectArrayに追加する
	dupptr ptr,varptr(shelllink),4	//IShellLinkへのポインタ
	
	if catid==-1{
		//タスクに追加
		IObjectCollection_AddObject task_category,ptr
	}else{
		IObjectCollection_AddObject categories(catid),ptr
	}
	delcom shelllink
	return
*/
#global
#packopt hide 1
cmd=dirinfo(4)	//引数
//ダイアログを出す命令に対応
if cmd=="/dialog"{
	dialog "ダイアログ"
	end
}
if instr(cmd,0,"/killme")==0{
	//この実装は少し適当。本当はもっとしっかり書いたほうがいい
	//0x10:WM_CLOSE
	sendmsg int(strmid(cmd,8,strlen(cmd)-8)),0x10,0,0
	end
}
gsel 0,1
beginJumpList
// タスクに追加する例
addNewShellLink -1,"電卓","calc.exe","","calc.exe",0
addNewShellLink -1,"メモ帳","notepad.exe","","notepad.exe",0
//カスタムカテゴリを作る例
makeCategory "カスタム項目"
catid=stat
addNewShellLink catid,"コマンドプロンプト","cmd.exe","","cmd.exe",0
commitCategory catid
makeCategory "カスタム項目2"
catid2=stat
this=getMyFilename()
// これは実行ファイルを作ってから使おう
addNewShellLink catid2,"ダイアログを出す",this,"/dialog",this,0
addNewShellLink catid2,"終了する",this,"/killme "+hwnd,this,0
commitCategory catid2
commitJumpList
stop
 
 
 
  |    |   
  
| 
 | 
 
2013/7/29(Mon) 10:15:27|NO.55951 
testさん、スクリプトどころかモジュールまで作ってくださってありがとうございました。 
 
いままで、ジャンプリストで苦戦していましたが、おかげさまで解決することが出来ました。 
これからもいろいろと頑張ってみようと思います。 
 
 |   
  
					 |