2017年4月19日水曜日

BaseElements の BE_ExecuteSystemCommandは、日本語ダメ!?#FileMaker

https://baseelementsplugin.zendesk.com/hc/en-us/articles/205350557-BE-ExecuteSystemCommand
FileMakerのPlugin、BaseElements の BE_ExecuteSystemCommand ( command { ; timeout } ) で、cmd.exe の戻り値が取得できるようなので試して見ましたが、日本語があるとダメな様子。

やっぱり、cmd.exe の戻り値取得は、以下の方法で!
FileMaker cmd.exe dirコマンドを実行して戻り値を取得。あれこれ。

2017年4月18日火曜日

FileMaker cmd.exe dirコマンドを実行して戻り値を取得。あれこれ。


■クリップボード経由
FileMakerスクリプト:
フィールド設定 [cmd::Result; ""]
コピー [選択; cmd::Result]
Event を送信 [「aevt」; 「odoc」; "cmd /c dir \"C:\Windows\" /b /a-d|clip"]
Loop
スクリプト一時停止/続行 [間隔(秒): 1]
貼り付け [選択; cmd::Result]
Exit Loop If [ not IsEmpty ( cmd::Result )]
End Loop
フィールドへ移動 []

PowerShell|fmpプロトコル を使用
スクリプト:FireCommand に引数 1 を指定して実行。
FileMakerスクリプト:
スクリプト名:FireCommand
If [ not IsEmpty ( $Return )]
フィールド設定 [cmd::Result; $return]
フィールドへ移動 []
現在のスクリプト終了 []
Else If [Get ( スクリプト引数 ) = 1]
変数を設定 [$Script; 値:Quote ( Substitute (
"$Rsult= cmd /c dir \"C:\Windows\" /b /a-d  ;
$return=$Rsult -join \"%0A\" ;
Start-Process ('fmp://$/" & Get ( ファイル名 ) & "?script=FireCommand&$Return='+$return);
" ; ¶ ; "" ) )]
Event を送信 [「aevt」; 「odoc」; "powershell -Command " & $Script ]
End If

プラグイン:ScriptMakerPS を使用
FileMakerスクリプト:
フィールド設定 [cmd::Result; SMPS_Exe( "cmd /c dir \"C:\Windows\" /b /a-d" )]


FileMakerの補助も出来る ProcessMakerTL を使用
※ProcessMakerTL.exe を起動しておく必要があります。
FileMakerスクリプト:
URL から挿入 [選択; ダイアログなし; cmd::Result; "http://127.0.0.1:8081/?target=cmd&Arguments=" & GetAsURLEncoded ( "/c dir \"C:\Windows\" /b /a-d" )]

2017年4月15日土曜日

PowerShell, SetForegroundWindow, SendWait

PowerShell, SetForegroundWindow, SendWait

Add-Type @"
  using System;
  using System.Runtime.InteropServices;
  public class FW {
     [DllImport("user32.dll")]
     [return: MarshalAs(UnmanagedType.Bool)]
     public static extern bool SetForegroundWindow(IntPtr hWnd);
      [DllImport("user32.dll")]
     public static extern IntPtr GetForegroundWindow();
  }
"@
$hWnd =$null
$FGhWnd =$null
add-type -AssemblyName System.Windows.Forms
$process_list = get-process -Name powershell
 foreach($process in $process_list){
$hWnd=$process.MainWindowHandle
[void][bool][FW]::SetForegroundWindow($hWnd)
Start-Sleep -m 10
$FGhWnd=[FW]::GetForegroundWindow()
if($hWnd -eq $FGhWnd){break}
}
if(($hWnd -eq $FGhWnd ) -and ( $hWnd-ne $null)){
[System.Windows.Forms.SendKeys]::SendWait("こんにちわ{ENTER}");
#[System.Windows.Forms.SendKeys]::SendWait("ipconfig{ENTER}");
"Sent"
}
$hWnd
$FGhWnd
$process.Name
$process.id