AbrirArquivos

Compartilhe seus scripts, funções, ferramentas e programas

Moderator: Gio

BeneditoCarneiro
Posts: 13
Joined: 04 Jul 2023, 11:29

AbrirArquivos

04 Jul 2023, 12:34

AbrirArquivos é um programa para abrir arquivos do Windows um pouco mais rápido que o Windows Explorer. O programa permite abrir arquivos e pastas listados, adicionar arquivos e pastas à lista, abrir arquivos não listados e criar arquivos e pastas.

Code: Select all

/*
Abrir e criar arquivos e pastas
Copyright 2023 Benedito Carneiro
Save the script as UTF-8 with BOM
*/
#NoEnv
#SingleInstance, Force
SendMode, Input
SetBatchLines, -1
SetWorkingDir, %A_ScriptDir%

bc := Chr(0169) . " 2023 Benedito Carneiro"
Gui, Font, s13 cYellow, Segoe UI
Gui, Color, 003366
Gui, Add, Text,, Abrir e criar arquivos e pastas
Gui, Font, cWhite
Gui, Add, Text,, Arquivos e pastas listados:
Gui, Add, Radio, gAbrir, Abrir um arquivo ou uma pasta
Gui, Add, Radio, gArquivos, Adicionar um arquivo à lista
Gui, Add, Radio, gPastas, Adicionar uma pasta à lista
Gui, Add, Radio, gEditar, Editar a lista
Gui, Add, Text,, Arquivos e pastas não listados:
Gui, Add, Radio, gOpenDir, Abrir um arquivo
Gui, Add, Radio, gNewFile, Criar um arquivo
Gui, Add, Radio, gNewDir, Criar uma  pasta
Gui, Add, Text,,
Gui, Add, Button,h30 w80 gSair, Sair
Gui, Font, cYellow
Gui, Add, Text,, %bc%
Gui, Show,,Abrir arquivos
return

Editar:
#IfWinActive, ahk_class Notepad
    WinClose, ahk_class Notepad
run, Notepad abrirArquivos.md
Return

Abrir:
FileRead, contents, abrirArquivos.md
if !ErrorLevel
{
    Sort, contents
    FileDelete, abrirArquivos.md
    FileAppend, %contents%, abrirArquivos.md, UTF-8
    Contents := ""
}
Loop, read, abrirArquivos.md
Menu, Menu1, Add, %A_LoopReadLine%, Acao1
Menu, Menu1, Color, CEE0F1
Menu, Menu1, Show
Menu, Menu1, DeleteAll
Return
Acao1:
Run, %A_ThisMenuItem%,, UseErrorLevel
if (ErrorLevel = "ERROR")
{
    MsgBox,16, Erro, Não achei o arquivo ou pasta %A_ThisMenuItem%.
    Return
}
Return

Arquivos:
FileSelectFile, arquivo,,, Selecione o arquivo
if ErrorLevel
    Return
FileAppend, `n%arquivo%, abrirArquivos.md
Return

Pastas:
FileSelectFolder, arquivo,,, Selecione a pasta
if ErrorLevel
    Return
FileAppend, `n%arquivo%, abrirArquivos.md
Return

OpenDir:
FileSelectFolder, diretorio,,, Selecione a pasta
If ErrorLevel
    Return
Loop %diretorio%\*.*
Menu, Menu2, Add, %A_LoopFileName%, Acao2
Menu, Menu2, Color, CEE0F1
Menu, Menu2, Show
Menu, Menu2, DeleteAll
Return
Acao2:
Run, %diretorio%\%A_ThisMenuItem%
Return

NewFile:
FileSelectFolder, diretorio,,, Selecione a pasta onde criar o novo arquivo.
If ErrorLevel
    Return
InputBox, newFile, Novo arquivo, Qual é o nome do novo arquivo?
If ErrorLevel
    Return
dir = %diretorio%`\%newFile%
If !FileExist(dir) {
    FileAppend,, %dir%
    If ErrorLevel
        MsgBox, 16, Erro, Ocorreu um erro. O arquivo não foi criado.
    Else MsgBox, 64, Successo, O arquivo foi criado.
} Else MsgBox, 48, Existe, O arquivo existe na pasta especificada.
Return

NewDir:
InputBox, newFolder, Nova pasta, Qual é o nome da nova pasta?
If ErrorLevel
    Return
FileSelectFolder, diretorio,,, Selecione onde criar a nova pasta.
If ErrorLevel
    Return
dir = %diretorio%`\%newFolder%
If !FileExist(dir) {
    FileCreateDir, %dir%
    If ErrorLevel
        MsgBox, 16, Erro, Ocorreu um erro. A pasta não foi criada.
    Else MsgBox, 64, Successo, A pasta foi criada.
} Else MsgBox, 48, Existe, A pasta existe no endereço especificado.
Return

GuiEscape:
GuiClose:
Sair:
Gui,destroy
ExitApp

[Mod action: Moved topic form the main part of the forum. Please only post in English in the main part of the forum.]

Return to “Scripts e Funções”

Who is online

Users browsing this forum: No registered users and 90 guests