satocchiaブログ
2026
2025
2024
2023
2022
2021
2020
2019
2018
2017
2016
2015
2014
2013
1月
2月
3月
4月
5月
6月
7月
8月
9月
10月
11月
12月
全1件 (1件中 1-1件目)
1
uwscの組み込みインプットボックス関数「input」は機能豊富ですが、入力ダイヤログのタイトルは自由に設定できません。 Option DlgTitleで値を設定すればその文字列、無指定なら "UWSC - "+Get_Uwsc_Nameがタイトルに表示されます。Option DlgTitleはinputのみならずmsgboxなどほかのUWSC組み込みダイヤログのタイトルと共用なので、使い勝手はよくありません。確か、途中で値を変更することもできません。検証スクリプト //option dlgtitleは何回も書けるが効果があるのは最後の1回だけ。//下のmsgboxは3回ともt「itle 2」msgbox("aaa")option dlgtitle="title 1"msgbox("aaa")option dlgtitle="title 2"msgbox("aaa") そこで、タイトル付きインプットボックス関数「inputbox」を作ってみました。<ポイント>VB.NETのinputboxはタイトルを付けられるので、powershell経由で呼びます。ただし、UWSCのpowershell関数からwindows.forms出力しても(VB.NETのinputboxもwindows.formらしい)、出力が隠されてしまいます。powershell関数の第三引数をtrueにすると表示できるがpowershellの出力を受け取れなくなってしまいます。そのため、inputboxを実行したらそのウインドウをctrlwin(id,show)してやります。同時並行処理となるのでスレッド展開します。ウインドウIDはinputboxのタイトル名とウインドウクラス名(先述の通り「WindowsFormsほにゃらら」)で指定します。念のため実行ファイルがpowershell.exeであることも確認しています。inputbox.uwsif GET_UWSC_NAME = "inputbox.uws" a=inputbox( "入力してください", "input_テスト中" ) msgbox(a)endiffunction inputbox( msg="", title=GET_UWSC_NAME ) src ="[void][Reflection.Assembly]::LoadWithPartialName(<#DBL>Microsoft.VisualBasic<#DBL>);" src =src+"[Microsoft.VisualBasic.Interaction]::InputBox(<#DBL>@@@msg@@@<#DBL>,<#DBL>@@@ittle@@@<#DBL>);" thread inputbox_sub( title ) result=powershell( replace( replace( src, "@@@msg@@@", msg ), "@@@ittle@@@", title ) )fendprocedure inputbox_sub(title) while true for id in getallwin() if status( id, st_title ) <> title then continue if pos( "WindowsForms", status( id, st_class ) )<> 1 then continue if pos( "powershell.exe", status( id, st_path ) ) = 0 then continue break 2 next wend ctrlwin( id, show ) ctrlwin( id, activate ) ctrlwin( id, normal )fend20190320追記えらく手間をかけていますが、uwscからSTAモードでpowershellを起動すれば、別スレッドで表示させなくてもウインドウが出てくれます。そこで関数をこうすれば簡単。function inputbox( msg="", title=GET_UWSC_NAME ) src="powershell -sta -command <#dbl>" src =src + "[void][Reflection.Assembly]::LoadWithPartialName('Microsoft.VisualBasic');" src =src + "[Microsoft.VisualBasic.Interaction]::InputBox('@@@msg@@@','@@@ittle@@@');<#dbl>" result=powershell( replace( replace( src, "@@@msg@@@", msg ), "@@@ittle@@@", title ) )fend
2019.01.10
コメント(0)