Keep script position in terminal

你说的曾经没有我的故事 提交于 2019-12-25 06:46:16

问题


I want to write a Powershell script that shows a few lines (maybe 5), but they stay in the same spot/position in the terminal window. For example: If I was writing a script that printed if a few devices were pingable, I wouldn't want the output to keep scrolling down the terminal; I would want each line to stay in the position they are in, but update over time.

Ex:

+----------------------+    +----------------------+
|       TERMINAL       |    |       TERMINAL       |
+----------------------+    +----------------------+
| Device1: PINGABLE    |    | Device1: NOT PINGABLE|
| Device2: NOT PINGABLE|    | Device2: NOT PINGABLE|
|                      |    |                      |
|                      |    |                      |
|                      |    |                      |
|                      |    |                      |
+----------------------+    +----------------------+

The script continues to run, the lines stay in the same place, and the output updates if necessary. How could I implement this in Powershell?

I just found this forum post that outlines my question more clearly: http://www.minasi.com/forum/topic.asp?TOPIC_ID=29171

Is this still the case? Is it still not possible?


回答1:


Take a look at $host.UI.RawUI and specifically $host.UI.RawUI.SetBufferContents(...).



来源:https://stackoverflow.com/questions/13572705/keep-script-position-in-terminal

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!