Sign in to follow this  
Followers 0
rafu5418

close and delete the file if it's opened

9 posts in this topic

#1 ·  Posted (edited)

Dear friends, im really worried about my project. i need a script which will monitor a particular 'win title' and delete that file form my hard drive if it's opened .. please guys help me !

Edited by rafu5418

Share this post


Link to post
Share on other sites



Dear friends, im really worried about my project. i need a script which will monitor a particular 'win title' and delete that file form my hard drive if it's opened .. please guys help me !

If it's opened how are you going to delete it?

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

script will terminate the process and then it will delete the file. Thank you

Share this post


Link to post
Share on other sites

WinList(), ProcessList(), WinGetProcess(), Something along those lines maybe. Im sure theres some Process UDF's around somewhere too.


# MY LOVE FOR YOU... IS LIKE A TRUCK- #

Share this post


Link to post
Share on other sites

how do i start ? any one have any examples ? it will be very help full ..

Share this post


Link to post
Share on other sites

Use Winlist() to list all the windows and if any matched just use ProcessClose() to kill it ?

As easy as that .

Share this post


Link to post
Share on other sites

the script will monitor a win title 'rafu'

if the title 'rafu' is opened the script will ProcessClose() and delete that file from location, where it's opened from.

Share this post


Link to post
Share on other sites

the script will monitor a win title 'rafu'

if the title 'rafu' is opened the script will ProcessClose() and delete that file from location, where it's opened from.

Ok. You have the algorithm. Now implement the AutoIt functions.

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

#Include <File.au3>

#Include <Array.au3>

#include<Date.au3>

#include <WinAPI.au3>

#include <Process.au3>

;---

$file= "rafu project"

;---

StringInStr($file, "rafu project")

;---

Func _Process_GetPath($iPID_In)

Local $hModule = 0

Local $hProc = 0

Local $stString = ''

Local $iResult = 0

Local $sPath = ''

$hProc = _WinAPI_OpenProcess(BitOR(0x0400, 0x0010), False, $iPID_In)

If Not $hProc Then Return SetError(1,0,0)

$stString = DllStructCreate("char[260]")

DllCall("Psapi.dll", "dword", "GetModuleFileNameEx", _

"hwnd", $hProc, _

"hwnd", $hModule, _

"ptr", DllStructGetPtr($stString), _

"dword", 260)

If @error Then Return SetError(2,0,0)

$sPath = DllStructGetData($stString, 1)

If $sPath = '' Then

Return SetError(3,0,0)

Else

Return $sPath

EndIf

EndFunc ;==>_GetProcPath

;---

While 1

sleep(50)

If WinWaitActive($file) Then

$iPID = WinGetProcess($file)

$sFullPath = _Process_GetPath($iPID)

ConsoleWrite ($sFullPath)

ConsoleWrite ($iPID)

WinKill($file)

FileDelete ($sFullPath)

FileDelete ($iPID)

EndIf

WEnd

;---

how do i delete the 'rafu project' file from my hard drive

please help me out !

Edited by rafu5418

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0