using System; using Arp.Prova.PlayLib; using Arp.Prova.ImageLibrary; using Arp.Prova.CsvLib; //Windowsのライブラリ using System.IO; using System.Windows.Forms; // 入力フォーム用ライブラリ using Arp.Prova.InputValueForm; //このサンプルコードは、入力フォームを表示し、入力された数値を基にCSVファイルからコンピューター名を取得します。 // CodeClass public class CodeClass { public static int CodeStart() { //変数を宣言 string strInputValue = string.Empty; string pcName = string.Empty; // PC個別設定ファイル(csv)読込む // 実行ファイル(exe)の一つ上の階層のSetting.csvファイルを指定 string sFilePath = Path.Combine(Path.GetDirectoryName(Application.StartupPath), "Setting.csv"); // 起動中のアプリを最小化 ////////////////////////////////////////////////////////////////////////////////////////// PlayLib.Window("", "Shell_TrayWnd").Unknown("TrayShowDesktopButtonWClass", "TrayShowDesktopButtonWClass").Click(); PlayLib.Sleep(1000); //入力フォームを宣言 // (コンストラクタの引数に、「ウインドウタイトル」と、「表示するメッセージ」を指定) InputValueForm inputvalForm = new InputValueForm("入力フォーム", @"設定番号を入力してください。(例:10) わからない場合はキャンセルをしてください。" ); //入力フォームを表示し、結果を取得(OK or キャンセル) DialogResult result = inputvalForm.ShowDialog(); //入力フォームがOKで閉じられた場合 if (result == DialogResult.OK) { // 入力値を取得 strInputValue = inputvalForm.GetValue(); // 入力値をログ出力 PlayLib.TestLog(strInputValue); if (!String.IsNullOrEmpty(strInputValue)) { try { //取得した数値と同じ行の"コンピューター名"項目の値を取得します。 pcName = CsvLib.GetField(sFilePath, "番号", strInputValue, "コンピューター名"); if (!String.IsNullOrEmpty(pcName)) { //取得したコンピューター名をLogViewerに出力します。 PlayLib.TestLog("コンピューター名:" + pcName); } else { PlayLib.TestLogError("入力された番号に対するコンピューター名は見つかりませんでした"); } } catch { PlayLib.TestLogError("入力値の取得に失敗しました"); return -1; } } else { PlayLib.TestLogError("入力値が空です"); return -1; } } else { PlayLib.TestLog("入力フォームがキャンセルされました"); } return 0; } }