.NET Logo
Welcome Guest Search | Active Topics | Members | Log In | Register

PowerShell ครั้งที่ 12 Options · View
paedotnet
Posted: Saturday, January 05, 2008 6:40:05 PM

Rank: มือเทพ
Groups: Member

Joined: 12/6/2007
Posts: 344
Location: bkk

การจัดการเกี่ยวกับ UI (User Interface)
เราสามารถจัดการกับ UI  ได้สองวิธีคือ 1 การตั้งค่าเองโดยเปิดโปรแกรม PowerShell แล้วคลิกที่มุมบนซ้ายรูป Icon  ดังรูป

 

จากนั้นเราสามารถตั้งค่าต่างๆได้ หลังจากนั้น ก็คลิกที่ปุ่ม OK แล้วจะมีหน้าต่างขึ้นมา ดังรูป

 

ในหน้าต่างนี้ จะมีให้เลือกอยู่สองตัวเลือกคือ
Apply properties to current window only คำสั่งนี้พอปิดโปรแกรม window powershell แล้วเปิดใหม่ก็จะลบค่าเดิมที่ตั่งไว้ออก ส่วนคำสั่ง Modify shortcut that started this window จะเป็นการ save ค่าที่เราตั่งไว้พอปิดโปรแกรมแล้วเปิดใหม่ก็จะได้ค่าเดิม
วิธีที่สอง จะเป็นการเขียนโปรแกรมเพื่อกำหนดค่าดังนี้
จะใช้คำสั่ง Get-Host ดังนี้


$i =  Get-Host
$i


ผลลัพธ์จะแสดงรายละเอียดของ Console
ถ้าเราต้องการเปลียนสี Background,foreground ของ Console ก็ใช้คำสั่ง


 $i = (Get-Host).UI.RawUI
$i.BackgroundColor = "Red"
$i.ForegroundColor = "Blue"


ผลลัพธ์แสดง ดังรูป


ถ้าต้องการเปลียนชื่อ Title เราก็ใช้คำสั่ง WindowTitle ดังนี้

$i.WindowTitle = "Hello"


ผลลัพธ์แสดงดังรูป


ถ้าต้องการเปลียนขนาด Window ก็เขียนได้ดังนี้
$s  =  $i.WindowSize
$s.Width = 50
$s.Height = 50
$i.WindowSize = $s

 



[With great power comes great responsibility]
Users browsing this topic
Guest


Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Main Forum RSS : RSS

YAFVision Theme Created by Jaben Cargman (Tiny Gecko)
Powered by Yet Another Forum.net version 1.9.1.8 (NET v2.0) - 3/29/2008
Copyright © 2003-2008 Yet Another Forum.net. All rights reserved.


Sponsored by