mfc 对话框接受键盘_愚蠢的怪胎技巧:使用键盘在“文件打开/保存”对话框中导航...

mfc 对话框接受键盘

mfc 对话框接受键盘

Sometimes in the life of a geek, we do something in front of a non-geek that shocks and amazes them. Sometimes it’s as simple as typing three keystrokes into a file open dialog. (At least it was for me yesterday)

有时,在极客的生活中,我们在非极客面前做一些令他们震惊和惊奇的事情。 有时,就像在文件打开对话框中键入三个击键一样简单。 (至少昨天是给我的)

I was doing some work on my computer with a friend sitting next to me, and her jaw dropped when she saw me navigating through the file open dialog with just the keyboard… so I decided to write up a number of other keyboard methods as well.

我正在和我旁边的一个朋友一起在计算机上做一些工作,当她看到我只用键盘浏览文件打开对话框时,她的下巴就掉了下来,所以我决定也写一些其他键盘方法。

Note: Expert geeks are excused from today’s lesson, but there’s extra credit for mentioning any methods that I forgot to include.

注意:今天的课程为专家级专家提供了借口,但提及我忘了包括的任何方法,也值得一提。

Navigate Up One Directory

浏览一个目录

This was what made my friend very surprised… as soon as any File Open/Save dialog is opened, just type .. (period period) and hit the Enter key:

这就是让我的朋友感到非常惊讶的原因……打开任何“文件打开/保存”对话框后,只需键入..(句号)并按Enter键:

image

After you hit the Enter key, you’ll notice you are suddenly in the next directory up…

按下Enter键后,您会发现您突然进入了下一个目录…

image

I’m sure you are less amazed than my friend was.

我敢肯定,你没有我的朋友那么惊讶。

Navigate by Relative Path

通过相对路径导航

You can type ..\ to get to the directory above the current one, and then start typing the name of a folder or filename.

您可以键入.. \进入当前目录上方的目录,然后开始键入文件夹或文件名的名称。

image

You could even use ..\..\ or any number of levels to continue to traverse up the directory tree.

您甚至可以使用.. \ .. \或任何数量的级别来继续遍历目录树。

Navigate with Shell Folders

使用Shell文件夹浏览

Included in Windows Vista (or XP) are a list of shell folder shortcut names that will let you type something as simple as shell:desktop to go to the desktop folder.

Windows Vista(或XP)中包含一个Shell文件夹快捷方式名称列表,您可以使用它们键入与shell:desktop一样简单的名称以转到桌面文件夹。

image

We’ve even got the full list of shell shortcuts for you.

我们甚至为您提供了完整的Shell快捷方式列表

Navigate with Environment Variables

浏览环境变量

You can use the built-in environment variables to quickly switch to a folder. For instance, to get to the Program Files folder you could type %programfiles%

您可以使用内置的环境变量来快速切换到文件夹。 例如,要进入Program Files文件夹,您可以键入%programfiles%

image

A better example would be %appdata%, which takes you to the C:\Users\<username>\AppData\Roaming folder.

一个更好的例子是%appdata%,它将带您到C:\ Users \ <用户名> \ AppData \ Roaming文件夹。

To see a full list of these variables, open a command prompt and type set. Just remember to surround the variable name with percent signs as shown in the example.

要查看这些变量的完整列表,请打开命令提示符并键入set。 只需记住如示例中所示,变量名用百分号括起来。

Navigate with UNC Paths

使用UNC路径浏览

Even if you don’t have a drive letter mapped to another computer, you can still open and save directly from a shared folder by typing in the UNC path to the server. Here’s the syntax:

即使您没有将驱动器号映射到另一台计算机,您仍然可以通过键入服务器的UNC路径直接从共享文件夹中打开和保存。 语法如下:

\\Servername\Sharename

\\服务器名\共享名

image

You’ll likely be prompted for your username and password to access that share (this would be the username on the computer you are trying to access, not the one you are on)

系统可能会提示您输入用户名和密码来访问该共享(这是您要访问的计算机上的用户名,而不是您所在的用户名)

image

Navigate with FTP

使用FTP导航

You can even connect to an FTP server to open a file by using the following syntax (thanks to freddo for mentioning this)

您甚至可以使用以下语法连接到FTP服务器以打开文件(感谢freddo提到了这一点)

ftp://user@servername/path/

ftp://用户@服务器名称/路径/

image

After you hit the Enter key, you’ll be prompted for your FTP password, and then you can browse the FTP site like a local folder. Note that this method will possibly be slow.

按下Enter键后,将提示您输入FTP密码,然后您可以像本地文件夹一样浏览FTP站点。 请注意,此方法可能会很慢。

Navigate with Full Paths

完整路径导航

You can just start typing the full path to a file if you’d like. It might take longer than some of the other options, but at least you’ve got full control.

您可以根据需要开始输入文件的完整路径。 它可能需要比其他一些方法更长的时间,但是至少您拥有完全的控制权。

image

Navigate with Copy and Paste

浏览复制和粘贴

In Windows Vista, if you hold down the shift key while right-clicking on a file or folder, there will be a new option called Copy as Path, which will copy the full path of that file or folder to the clipboard.

在Windows Vista中,如果在右键单击文件或文件夹的同时按住Shift键,将有一个名为“复制为路径”的新选项,它将复制该文件或文件夹的完整路径到剪贴板

You can then paste that path into the File name box and hit the Enter key to open it.

然后,您可以将该路径粘贴到“文件名”框中,然后按Enter键将其打开。

image

Note that you could use the keyboard to paste the path in, but I couldn’t really take a screenshot of that.

请注意,您可以使用键盘将路径粘贴到其中,但是我无法真正截取该屏幕截图。

Many of these methods work in other operating systems as well… for instance, you can use the ../../ method on Linux.

这些方法中的许多方法也可以在其他操作系统中使用……例如,您可以在Linux上使用../../方法。

翻译自: https://www.howtogeek.com/howto/windows-vista/stupid-geek-tricks-navigate-in-the-file-opensave-dialog-with-the-keyboard/

mfc 对话框接受键盘

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值