.net console app with hyperlinks?

拈花ヽ惹草 提交于 2019-12-10 20:52:10

问题


is it possible ? any samples/patterns or ideas on how to go about it ?

Update - this essentially becomes a text browser which displays various tables of information based on various commands on the prompt like typing the url in a browser

now instead of typing various commands like

prompt>command arg1 arg2 if only you could say "click" on the text in a certain "column"/"row" which would execute the command say

prompt>commandX arg1

it'd be somewhat faster/easier

Now, before someone mentions doing a typical browser/asp.net mvc/whatever app, i already have that running but have encountered some limitations esp. with accesing network files. etc. Now that's taken care of using a service-broker service which reads the file etc. but having added numerous extensions to it, it'd be somewhat easier if you could just run the app as a console prompt with a mvc pattern and add extensions to it etc. etc.

if only the text is clickable, it'd make it more friendly for use !!


回答1:


The window's shell doesn't support clickable hyperlinks, so no, this isn't possible.

What are you trying to do that warrants the need for hyperlinks in the command shell? Perhaps this application would be better built as a WinForms/WPF or ASP.NET application.




回答2:


Assuming no mouse, I would just launch the URL as a new process based on some keyboard trigger.

// this will launch the default browser    
ProcessStartInfo psi = new ProcessStartInfo("https://stackoverflow.com");
Process p = new Process(psi);
p.Start();

VB syntax:

// this will launch the default browser
Dim psi = New ProcessStartInfo("https://stackoverflow.com")
Dim p As Process = Process.Start(psi)



回答3:


I don't know what a "hyperlink" is for you, but in the context of a Console Application, you can have numbers or letters that you are expecting the user to press

(imagine a simple menu with 3 options)

Press one option

1 - Open ServerFault
2 - Open StackOverflow 
3 - Open SuperUser

and in the readline you have a switch that start the IExplorer process for example and opens the webpage.

Is that what you call regarding "hyperlinks in a console application"?




回答4:


For an idea of what it can look like, get your hands on a copy of links. It's a text-mode web browser that works just fine in several operating systems.




回答5:


you can access the mouse from the console, if you wish to have clickable elements in your console application. you'll have to build the logic yourself of course for the clickable areas.

http://cboard.cprogramming.com/windows-programming/38680-win32-console-app-mouse-input.html



来源:https://stackoverflow.com/questions/1246579/net-console-app-with-hyperlinks

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