Code: Select all
"C:\Program Files\AutoHotkey\AutoHotkey.exe" FileRecycle, C:\000\*.txt
Code: Select all
"C:\Program Files\AutoHotkey\AutoHotkey.exe" FileRecycle, C:\000\*.txt
Code: Select all
q::
FileDelete, ~.ahk
FileAppend,
(
FileRecycle, C:\000\*.txt
),~.ahk, UTF-8
Run, ~.ahk
Return
Code: Select all
#warn
setworkingdir,%a_scriptdir%
wa:=a_screenwidth
ha:=a_screenheight
W :=(wa*50)/100 ;- width
H :=(ha*92)/100 ;- height
files=%a_desktop%\000\*.txt ;- delete txt-files from here ( parameter /P asks for Y/N )
;- some dos commands example
e4x=
(Ltrim join&
@echo off
echo date=
date /t
echo time=
time /t
ver
del /P /S %files%
)
title2=DOS_TEST
run, %comspec% /T:0A /k "title %title2%&mode con lines=4000 cols=120&%e4x%,,,pid2
WinWait, ahk_pid %pid2%
WinMove, ahk_pid %pid2%, ,1,1,%w%,%h% ;- move DOS window to the defined position
return
Thank you for your reply!
Yes, it's same as ahk-command 'Filedelete' , so use ahk-command 'Filerecycle' , moves to 'RecycleBin'As far as I know, dos commands DEL or ERASE simply delete the files from the disk completely, rather than moving them to the recycle being as the ask command FileRecycle does.
Code: Select all
@ECHO OFF
DEL onelinescript.ahk
ECHO %* > onelinescript.ahk
START /w onelinescript.ahk
DEL onelinescript.ahk
Code: Select all
;==================================================
;func runner
;examples (call script from an AHK script):
;Run, "%A_Desktop%\func runner.ahk" MyMsgBox "hello world"
;Run, "%A_Desktop%\func runner.ahk" MyMsgBox hello
;Run, "%A_Desktop%\func runner.ahk" FileRecycle "%A_Desktop%\New Text Document.txt"
;examples (call script from a batch file):
;"C:\Users\%username%\Desktop\func runner.ahk" MyMsgBox "hello world"
;"C:\Users\%username%\Desktop\func runner.ahk" MyMsgBox hello
;"C:\Users\%username%\Desktop\func runner.ahk" FileRecycle "C:\Users\%username%\Desktop\New Text Document.txt"
;==================================================
if (A_Args.1 = "")
{
MsgBox, % "error: no function specified"
}
vFunc := A_Args.RemoveAt(1)
if !oFunc := Func(vFunc)
{
MsgBox, % "error: invalid function"
}
%oFunc%(A_Args*)
return
;==================================================
MyMsgBox(Text)
{
MsgBox, % Text
}
;==================================================
;commands as functions (AHK v2 functions for AHK v1) - AutoHotkey Community
;https://autohotkey.com/boards/viewtopic.php?f=37&t=29689
FileRecycle(FilePattern)
{
FileRecycle, % FilePattern
return !ErrorLevel
}
;==================================================
Copy that code I posted into a new batch file, save it as "a.cmd" - place that somewhere in your "path" environment, say c:\windows\ - that way you can call it from any directory in a dos command window by simply typing "a"surfactant wrote: ↑28 Jun 2019, 13:08What did you mean? Where do you put the a MsgBox Hello There to run? Thanks!
Code: Select all
echo MsgBox Hi | "C:\Program Files\AutoHotkey\AutoHotkey.exe" *
Code: Select all
@echo %* | "C:\Program Files\AutoHotkey\AutoHotkey.exe" *
Code: Select all
ahk MsgBox, 64, Hello, World
Users browsing this forum: jaka1, marypoppins_1, mikeyww, OrangeCat, RussF and 132 guests