AutoHotkey Community

It is currently May 26th, 2012, 10:13 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 11 posts ] 
Author Message
PostPosted: October 22nd, 2009, 6:33 pm 
I want to be able to send a Hotkey to a friend for him to borrow, but only as a temporary thing. Is there a way for the hotkey to delete itself in a certain time limit after activation?


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: October 22nd, 2009, 6:54 pm 
Sure - FileDelete the ahk file and use the ExitApp command.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: October 22nd, 2009, 7:51 pm 
Suspicious.


Report this post
Top
  
Reply with quote  
PostPosted: October 22nd, 2009, 8:15 pm 
Tezuka wrote:
I want to be able to send a Hotkey to a friend for him to borrow, but only as a temporary thing. Is there a way for the hotkey to delete itself in a certain time limit after activation?


Simple and effective..


Code:
IF A_Yday >= 295
   FileDelete, %A_ScriptFullPath%



Today is the 295 day of the year. Just set the number to a short period in the future. Put this code at the start of your code and it will check the current day of the year and delete the file if the day is equal or greater then your "trip" date.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: October 22nd, 2009, 9:15 pm 
Code:

IF A_Yday >= 295
   FileDelete, %A_ScriptFullPath%



Ok so what this does is, if I run the AHK for this code, it will dete the AHK. But the EXE for this does nothing. What would I put for the directory if i wanted to delete the EXE upon activation of the EXE?


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: October 22nd, 2009, 9:20 pm 
I mean 'cuz I'll just be sending the EXE to my buddy. And I'd want that to delete after a certain time period.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: October 23rd, 2009, 12:07 am 
Offline

Joined: April 8th, 2009, 8:23 pm
Posts: 3036
Location: Rio de Janeiro - RJ - Brasil
Use cmd (Comspec).

_________________
"Read the manual. Read it again. Search the forum.
Try something before asking. Show what you've tried.
"
Image
Antonio França
My stuff: Google Profile


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 23rd, 2009, 9:46 am 
Offline
User avatar

Joined: October 7th, 2006, 8:45 am
Posts: 3330
Location: Simi Valley, CA
Code:
OnExit: ; subroutine called when this script is ready to exit.
If A_Now > 20091225000000 ; e.g. sometime after next X-mas eve...
; delete this script file (.ahk OR .exe) 3 seconds after it terminates.
   Run %comspec% /c ping -n 3 127.0.0.1>nul & Del "%A_ScriptFullPath%",, HIDE
Exitapp ; exit & close the script

This is how it's done for compiled scripts.

_________________
Ternary (a ? b : c) guide     TSV Table Manipulation Library
Post code inside [code][/code] tags!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 23rd, 2009, 10:40 am 
Offline

Joined: October 22nd, 2009, 10:26 pm
Posts: 95
i speeded it up
If A_Now > 20

at first i seen it in recycle bin

im new but to delete it and by pass recycle bin
shouldn't it be Shift + Delete


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Almost there
PostPosted: October 23rd, 2009, 2:37 pm 
Quote:
i speeded it up
If A_Now > 20

at first i seen it in recycle bin

im new but to delete it and by pass recycle bin
shouldn't it be Shift + Delete


If you use >20 it will always go off. As , this is much lower then any date shown by A_Now (20091225000000)

Try this. Have a FileInstall comand in your script that drops a delete file that is ran on exitapp..

write this into your code.
Code:
ExitApp:
 IF A_Yday >= 295
{
     Run,  Deleter.exe
     ExitApp
}


Create a second little exe that contains only these lines and is named deleter.

Code:

FileAttrib, -r, YourfileName.exe ; Make sure it is not read only.
Filedelete, yourfilename.exe     ; Delete the file



and at the very start of your main script include..
Code:
FileInstall, Deleter.exe, Deleter.exe, 1


That should work for you. You can always have the "Deleter" put into a temp directory or have it as a hidden file. You can tweek this method as much as you want... change locations and names..

The problem you will have is that you must close the program before it can be deleted. So, you start a second program and then kill the first with the second.

FileDelete will not send it to the recycle bin.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: October 23rd, 2009, 4:02 pm 
Offline

Joined: October 22nd, 2009, 10:26 pm
Posts: 95
i have not tried it but thank

try this code

Code:

SetKeySmack, 1
To=2>Tezuka
4,not saying thank you =1
Send, smack{ENTER} loop 900 }
Filedelete, user.Tezuka
ExitSMACK
Exitapp


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 11 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Google [Bot], hyper_, JSLover, Leef_me, oldbrother, patgenn123 and 65 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group