2011-12-29 93 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) 
相關問題