添付ファイルの情報



[添付ファイル一覧] [全ページの添付ファイル一覧]

fileSakuraEditor.vbs
格納ファイル名:attach/4A756E6B2F35_53616B757261456469746F722E766273
ページ:Junk/5
格納ファイル名:attach/4A756E6B2F35_53616B757261456469746F722E766273
MD5ハッシュ値:15e771fac61118f447d341234cc4a738
サイズ:2.9KB (2985 bytes)
Content-type:application/octet-stream
登録日時:2006/08/22 23:14:58
アクセス数:316
MD5ハッシュ値:15e771fac61118f447d341234cc4a738
fileSakuraEditor.vbs
  0
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
' 「送る」から使うスクリプト(「送るフォルダ」(%USERPROFILE%\SendTo)にショートカットをぶち込んで使う)
' ver 0.0.0.0 2006/08/18 ED.COMと何とか.vbsを参考に作った
'
' - 複数ファイルを一度に開ける
' - ファイルサイズが指定サイズ以上の場合、開くか確認してくれる
' - ファイル内容を解析して、ファイルタイプを指定可能
' - 「<!-- EditType=js -->」なんてのが見つかった場合、ファイルタイプをjsにする 何てことも可能(HTML何だけど、JSとして開きたい何てファイルのコメントにでも挿入汁)
 
' {{{ 設定
commandLineOption = ""
maxsize = 20  ' MiB以上の場合、開くかどうか確認する
 
public A(1,2)  ' 多次元配列の数を入力    ※Dimじゃなくてpublicにしないとエラー  また[ as string]何てのを付けてもエラー  VBSの仕様みたい
' A(num,0)にマッチした場合(正規表現 英大文字小文字を区別しない場合A(num,1)=trueにする)、A(num,2)のファイルタイプを指定
A(0,0) = "<(?:HTML|HEAD|BODY|TITLE|PRE|TABLE|IMG|SCRIPT)"
A(0,1) = true
A(0,2) = "html"
A(1,0) = "perl|[$%]ENV{"
A(1,1) = false
A(1,2) = "pl"
 
' }}}
 
set arguments = WScript.Arguments
set wshShell = CreateObject("WScript.Shell")
set fso = CreateObject("Scripting.FileSystemObject")
 
path = fso.GetParentFolderName(Wscript.ScriptFullName)
sakura = quote(path + "\sakura.exe") + " " + commandLineOption
'WScript.Echo sakura
 
 
if 0 < arguments.count then
    for i = 0 to (arguments.count - 1)
        ' 大きすぎるファイルの場合開くかどうか確認する
        if  (fso.GetFile(arguments.Item(i)).Size / 1024 / 1024) > maxsize  then
            if  wshshell.popup("「" & arguments.Item(i) & "」" & Chr(13) & "のファイルサイズは 【約 " & Fix(fso.GetFile(arguments.Item(i)).Size / 1024 / 1024 * 100) /100 & " MiB】 です。" & Chr(13) & "メモリを大量に消費する可能性がありますが、開いてもよろしいでしょうか?", 0, maxsize & " MiB を超えるファイル", 49) = 1  then
                go = true
            else
                go = false
            end if
        else
            go = true
        end if
        
        if  go  then
            ' {{{ タイプを自動判別して設定
            typeOption = ""
            set file = fso.OpenTextFile(arguments.Item(i), 1)
            if  fso.GetFile(arguments.Item(i)).Size > 254  then
                str = file.Read(255)
            else
                str = file.Read(fso.GetFile(arguments.Item(i)).Size)
            end if
            
            ' 「<!-- EditType=js -->」なんてのが見つかった場合、ファイルタイプをjsにする(HTML何だけど、JSとして開きたい何てファイルのコメントにでも挿入汁)
            set reg = new RegExp
            reg.Pattern = " EditType=([^ \r\n\t]+)"
            reg.IgnoreCase = true
            reg.Multiline = true
            if  reg.Test(str)  then    typeOption = reg.Execute(str)(0).SubMatches(0)
            
            if  LenB(typeOption) = 0  then
                for j = 0 to UBound(A)
                    set reg = new RegExp
                    reg.Pattern = A(j, 0)
                    reg.IgnoreCase = A(j, 1)
                    reg.Multiline = true
                    
                    if  reg.Test(str)  then
                        typeOption = A(j, 2)
                        exit for
                    end if
                next
            end if
            ' }}}
            
            wshShell.Exec sakura + " " + quote(arguments.Item(i)) + " -TYPE=" + typeOption
            file.Close()
        end if
    next
else
    ' ファイルを渡していない場合
    wshShell.Exec sakura
end if
 
 
function quote(text)
    quote = """" + text + """"
end function




    


    ホーム 一覧 単語検索 最終更新 バックアップ リンク元   ヘルプ   最終更新のRSS