【HSP3】VOICEROID+ 東北ずん子をHSPから制御するモジュール Ver 0.01

VOICEROID+ 東北ずん子をHSPから制御するモジュールです。前シリーズと仕様が変わっています。NGワード系の処理が入っていません。

VOICEROID+ 東北ずん子をHSPから制御するモジュールです。前シリーズと仕様が変わっています。NGワード系の処理が入っていません。

#include "user32.as"
#include "kernel32.as"
#module __VOICEROID_ZUNKO__
#deffunc zunko_init
	// ウィンドウ名とかクラス名とか
	zunkowname1 = "VOICEROID+ 東北ずん子*"
	zunkowname2 = "VOICEROID+ 東北ずん子"
	zunkomainclass = "WindowsForms10.Window.8.app.0.17ad52b"
	zunkoeditclass = "WindowsForms10.RichEdit20W.app.0.17ad52b"
	zunkobuttonclass = "WindowsForms10.BUTTON.app.0.17ad52b"
return
// ボイスロイドの起動数を調べる
#defcfunc GetZunkoRunningNumV
	h = 0 : c = 0
	repeat
		FindWindowExA 0, h, zunkomainclass, zunkowname1
		if stat == 0{
			FindWindowExA 0, h, zunkomainclass, zunkowname2
		}
		h = stat
		// 0 になるまでループ
		if h == 0 {
			c = cnt : break	
		}
	loop
return c
// ボイスロイドのトップのウィンドウを取得
#defcfunc GetZunkoTopWindowV
	FindWindowA zunkomainclass, zunkowname1
	if stat == 0{
		FindWindowA zunkomainclass, zunkowname2
	}
return stat
// ボイスロイドのテキストボックスを取得
#defcfunc GetZunkoTextBoxV
		FindWindowExA GetZunkoTopWindowV(), 0, zunkomainclass, 0
		hChild = stat
		FindWindowExA hChild, 0, zunkomainclass, 0		// その子を取得(長男)
		FindWindowExA hChild, stat, zunkomainclass, 0	// 2番目(次男)
			hChild = stat
			FindWindowExA hChild, 0, zunkomainclass, 0		// 2番目の兄弟の孫(長男)を取得
			FindWindowExA stat, 0, zunkomainclass, 0
			FindWindowExA stat, 0, zunkomainclass, 0
			FindWindowExA stat, 0, zunkomainclass, 0
				hChild = stat
				FindWindowExA hChild, 0, zunkoeditclass, 0
return stat
// ボイスロイドの再生ボタンを取得
#defcfunc GetZunkoPlayButtonV
		FindWindowExA GetZunkoTopWindowV(), 0, zunkomainclass, 0
		hChild = stat
		FindWindowExA hChild, 0, zunkomainclass, 0		// その子を取得(長男)
		FindWindowExA hChild, stat, zunkomainclass, 0	// 2番目(次男)
			hChild = stat
			FindWindowExA hChild, 0, zunkomainclass, 0		// 2番目の兄弟の孫(長男)を取得
			FindWindowExA stat, 0, zunkomainclass, 0
			FindWindowExA stat, 0, zunkomainclass, 0
			FindWindowExA stat, 0, zunkomainclass, 0
				hChild = stat
				FindWindowExA hChild, 0, zunkomainclass, 0
					hChild = stat
					FindWindowExA hChild, 0, zunkobuttonclass, 0
return stat
// ボイスロイドの停止ボタンを取得
#defcfunc GetZunkoStopButtonV
		FindWindowExA GetZunkoTopWindowV(), 0, zunkomainclass, 0
		hChild = stat
		FindWindowExA hChild, 0, zunkomainclass, 0		// その子を取得(長男)
		FindWindowExA hChild, stat, zunkomainclass, 0	// 2番目(次男)
			hChild = stat
			FindWindowExA hChild, 0, zunkomainclass, 0		// 2番目の兄弟の孫(長男)を取得
			FindWindowExA stat, 0, zunkomainclass, 0
			FindWindowExA stat, 0, zunkomainclass, 0
			FindWindowExA stat, 0, zunkomainclass, 0
				hChild = stat
				FindWindowExA hChild, 0, zunkomainclass, 0
					hChild = stat
					FindWindowExA hChild, 0, zunkobuttonclass, 0
					FindWindowExA hChild, stat, zunkobuttonclass, 0
return stat
// ボイスロイドのテキストボックスを全選択する
#deffunc ZunkoTextAllSelectV
	sendmsg GetZunkoTextBoxV(), /*EM_SETSEL*/0x00B1, 0, -1
return stat
// ボイスロイドのテキストボックスにクリップボード経由で貼り付け
#deffunc ZunkoTextPasteV
	sendmsg GetZunkoTextBoxV(), 0x0301/*WM_COPY*/, 0, 0
return stat
// ボイスロイドのテキストボックスをUNDO
#deffunc ZunkoTextUndoV
	sendmsg GetZunkoTextBoxV(), 0x0304/*WM_UNDO*/, 0, 0
return stat
// ボイスロイドのテキストボックスを切り取る
#deffunc ZunkoTextCutV
	sendmsg GetZunkoTextBoxV(), 0x0300/*WM_CUT*/, 0, 0
return stat
// ボイスロイドのテキストボックスをコピー
#deffunc ZunkoTextCopyV
	sendmsg GetZunkoTextBoxV(), 0x0301/*WM_COPY*/, 0, 0
return stat
// ボイスロイドのテキストボックスを消去(選択されてるか所のみを消します)
#deffunc ZunkoTextDeleteV
	sendmsg GetZunkoTextBoxV(), 0x0303/*WM_CLEAR*/, 0, 0
return stat
// ボイスロイドのテキストボックスを消去(選択されてなくても消します)
#deffunc ZunkoTextDelete2V
	msg = ""
	sendmsg GetZunkoTextBoxV(), 0x000C/*WM_SETTEXT*/, 0, varptr(msg)
return stat
// テキストボックスに代入します(直接)
#deffunc ZunkoSetTextV str _msg
	msg = _msg
	sendmsg GetZunkoTextBoxV(), 0x000C/*WM_SETTEXT*/, 0, varptr(msg)
return stat
// テキストを再生します。
#deffunc ZunkoPlayTextV
	sendmsg GetZunkoPlayButtonV(), 0x00F5/*BM_CLICK*/, 0, 0 
return
// テキスト再生を停止します。
#deffunc ZunkoStopTextV
	sendmsg GetZunkoStopButtonV(), 0x00F5/*BM_CLICK*/, 0, 0 
return
// 再生中かチェック(再生中の場合は1)
// 0 停止中 1 再生中 2 一時停止中
#defcfunc IsZunkoPlayingV
	sdim tmp, 64
	sendmsg GetZunkoPlayButtonV(), 0x000D/*WM_GETTEXT*/, 64-1, varptr(tmp)
	if stat == 0 : return 0
	if instr(tmp, 0, "一時停止") != -1 {
		return 0
	}else : if instr(tmp, 0, "再開") != -1{
		return 2
	}
return 1
#global
// ↓これは必ず必要
zunko_init

	// サンプル
	
	// 起動している場合は 1以上が返る。
	if GetZunkoRunningNumV() > 0 {
		ZunkoSetTextV "東京特許許可局"
		ZunkoPlayTextV
	}