satocchiaブログ

satocchiaブログ

PR

×

キーワードサーチ

▼キーワード検索

カレンダー

コメント新着

tomoZo@ Re:Pale Moon日本語化トラブル(06/06) はじめまして。 28.16.0でまたもや提供さ…
satocchia @ Re[1]:Pale Moon日本語化トラブル(06/06) zui_9さんへ 本日、確認しました。ようや…
zui_9 @ Re:Pale Moon日本語化トラブル(06/06) 上記リンク「Githubのプロジェクト」の左…
わたなべ@ Re:powershellコンソール、見づらくありませんか?(08/26) 初めまして、この情報最高です! 背景を白…
y__@ Re:uwscでGUIフォーム(05/12) UWSC 仮掲示板から飛んできました。 HTAで…
2018.02.20
XML
カテゴリ: UWSC
要は、いちいちpowershellを呼び出すんじゃなくて、一回起動した後何らかのプロセス間通信でUWSCとやり取りすればいい。
で、UWSCってウインドウの中身とか受け取るのが得意。そういうわけで、目に見えないWindows.Forms.Formをこさえてやりとりしたらいいんじゃないかな。

掲示板の依頼でつくったやつ。アイコンをクリックORキーボードでフォーカスするとアイコンのパスを表示するスクリプト。

いちいちバージョン 遅い 

sendstr(0,"")
while !getkeystate( vk_q )
    fukidasi( getIconPath() )
    sleep( 0.1 )
wend
exitexit

function    getIconPath()
    id  =getid( GET_ACTIVE_WIN )
    if status( id, st_class ) <> "Progman"  and status( id, st_class ) <> "cabinetWClass"
        result  =""
        exit
    endif
    kbd( VK_ctrl, down )
    kbd( VK_c, click )
    kbd( VK_ctrl, up )
    result  =getClipPath()
fend
function    getClipPath()
    result  =powershell_STA( getClipPath.src )
    module getClipPath
textblock src
[void][reflection.assembly]::loadwithpartialname("System.Windows.Forms")
if (  [windows.forms.clipboard]::ContainsFileDropList() ){
     [windows.forms.clipboard]::getFileDropList()
}
endtextblock
    endmodule
fend
function    powershell_STA( src )
    encodedSource   =powershell( "[Convert]::ToBase64String([System.Text.Encoding]::Unicode.GetBytes( '" + src + "' ))" )
    encodedSource   =replace( encodedSource, "<#CR>", "" )
    result  =powershell( "powershell -sta -EncodedCommand " + encodedSource )
fend

No.5143 2018/02/19(Mon) 08:40:56

速いバージョン 1回powershellを起動するだけ。
 にしても、Windows.Formsの扱いは面倒。RunSpacePoolとかで起動してやらないと、リアルタイムに書き込みできない。

sendstr(0,"")
thread getClipPath()
while !getkeystate( vk_q )
    fukidasi( getIconPath() )
    sleep( 0.1 )
wend
exitexit

function    getIconPath()
    id    =getid( GET_ACTIVE_WIN )
    if status( id, st_class ) <> "Progman"  and status( id, st_class ) <> "cabinetWClass"
        result    =""
        exit
    endif
    kbd( VK_ctrl, down )
    kbd( VK_c, click )
    kbd( VK_ctrl, up )
    id0    =getid( "getClipPath_hiddenDialog" )
    if status( id0, st_isid )
        result=getstr( id0, -1, STR_STATIC )
    else
        result=""
    endif
fend
procedure    getClipPath()
    uwsc_pid    =status( getid( GET_THISUWSC_WIN ), ST_PROCESS )
    src            =replace( getClipPath.src, "<PID>", uwsc_pid )
    powershell_STA( src )
    module getClipPath
textblock src
[void][reflection.assembly]::loadwithpartialname("System.Windows.Forms")
$UWSC_pid="<PID>"
$form=new-object system.windows.forms.form
$form.text="getClipPath_hiddenDialog"
$form.formborderstyle="none"
$form.opacity=0.01
$label=new-object system.windows.forms.label
$label.parent=$form
$rs = [Management.Automation.Runspaces.RunspaceFactory]::CreateRunspace()
$rs.Open()
$rs.SessionStateProxy.SetVariable("form",$form)
$p = $rs.CreatePipeline( { [void] $form.ShowDialog() } )
$p.Input.Close()
$p.InvokeAsync()
do{
    if ( [windows.forms.clipboard]::ContainsFileDropList() ){
        $pathstr    =[windows.forms.clipboard]::getFileDropList()
         $label.text=$pathstr
    } else {
        $label.text=""
    }
    if ( !( gwmi win32_process|?{$_.processID -eq $UWSC_pid } ) ) {
        break
    }
} while ( $true )
endtextblock
    endmodule
fend
procedure    powershell_STA( src )
    encodedSource    =powershell( "[Convert]::ToBase64String([System.Text.Encoding]::Unicode.GetBytes( '" + src + "' ))" )
    encodedSource    =replace( encodedSource, "<#CR>", "" )
    powershell( "powershell -sta -EncodedCommand " + encodedSource, true )
fend





お気に入りの記事を「いいね!」で応援しよう

最終更新日  2018.02.20 10:32:45
コメント(0) | コメントを書く
[UWSC] カテゴリの最新記事


【毎日開催】
15記事にいいね!で1ポイント
10秒滞在
いいね! -- / --
おめでとうございます!
ミッションを達成しました。
※「ポイントを獲得する」ボタンを押すと広告が表示されます。
x
X

© Rakuten Group, Inc.
X
Design a Mobile Site
スマートフォン版を閲覧 | PC版を閲覧
Share by: