2011-12-29 54 views
0

该平台是Windows XP的x86。在Windows中从ruby代码弹出指令的最简单方法是什么?

我想写一个函数,如pop_up_instruction(),当调用它时,应该有一个弹出对话框或记事本或命令行或任何其他的打印指令块。

指包含“\ r \ n”,像这样的:

Explorer [/n] [/e] [(,)/root,<object>] [/select,<object>] 

/n    Opens a new single-pane window for the default 
        selection. This is usually the root of the drive Windows 
        is installed on. If the window is already open, a 
        duplicate opens. 
/e    Opens Windows Explorer in its default view. 
/root,<object> Opens a window view of the specified object. 
/select,<object> Opens a window view with the specified folder, file or 
        application selected. 

我写了一个函数上述字符串转换成一个VB字符串,并将其打印到一个VBS文件,并调用这个VBS文件中使用系统(the_vbs_file),the_vbs_file内容:

MsgBox "Explorer [/n] [/e] [(,)/root,<object>] [/select,<object>]" & vbCrLf & _ 
    "" & vbCrLf & _ 
    "/n    Opens a new single-pane window for the default" & vbCrLf & _ 
    "     selection. This is usually the root of the drive Windows" & vbCrLf & _ 
    "     is installed on. If the window is already open, a" & vbCrLf & _ 
    "     duplicate opens." & vbCrLf & _ 
    "/e    Opens Windows Explorer in its default view." & vbCrLf & _ 
    "/root,<object> Opens a window view of the specified object." & vbCrLf & _ 
    "/select,<object> Opens a window view with the specified folder, file or" & vbCrLf & _ 
    "     application selected." & vbCrLf & _ 
    "" 

我们是否有其他更好的办法?

+0

@pguardiario,冷静,谢谢! – aaron 2011-12-29 15:17:46

+0

此外,是否可以弹出一些窗口,我们可以选择文本并复制它? – aaron 2011-12-29 15:18:43

回答

0

你应该看看WIN32API:

require "Win32API" 
title, message = 'dialog title', "line 1\nline 2" 
Win32API.new('user32','MessageBox',['L', 'P', 'P', 'L'],'I').call(0,message,title,0) 
相关问题