DonationCoder.com forum
 
Read-only archive. This is a static copy of the DonationCoder.com forum. Reading and searching work as before; logging in, posting and private messages do not.
Archive of 2026-10-21 · About this archive · Main site

Last post Author Topic: AHK Help anyone?  (Read 27,685 times)

ak_

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 223
Re: Request for AHK help...I feel so dumb...
« Reply #25 on: August 16, 2007, 10:27 AM »
Here's how i would do it :
Code
Activate:
Loop %ProgramFiles%\Dr. Windows\*.exe
{
  FileList = %A_LoopFileLongPath%`n%FileList%
}
StringSplit File, FileList, `n
random rnd, 1, %File0%
fileToRun = File%rnd%
fileToRun := %fileToRun%
Run %fileToRun%

Maybe there's a simpler solution but it works.
« Last Edit: August 16, 2007, 10:32 AM by ak_ »

wreckedcarzz

  • Still lurking. Still an anthro.
  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 1,629
    • Participated in NANY Challenge Twice
    • Coding Snacks
    • Furry Fandom Badge - Furry Fandom
    • Linux User
Re: Request for AHK help...I feel so dumb...
« Reply #26 on: August 17, 2007, 01:38 AM »
OK cool, I will give it a go and see what happens. Thanks a lot, this was really getting annoying getting irrelevant search results  :)

ak_

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 223
Re: Request for AHK help...I feel so dumb...
« Reply #27 on: August 17, 2007, 03:56 AM »
You're welcome :)

By the way, i found out that this has the same result and takes less code :
Code
Loop %ProgramFiles%\Dr. Windows\*.exe
{
  FileList = %A_LoopFileLongPath%`n%FileList%
}
StringSplit File, FileList, `n
random rnd, 1, %File0%
Run % File%rnd%

I didn't know about this "% " thing and it's very convenient.

wreckedcarzz

  • Still lurking. Still an anthro.
  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 1,629
    • Participated in NANY Challenge Twice
    • Coding Snacks
    • Furry Fandom Badge - Furry Fandom
    • Linux User
Re: AHK Help anyone?
« Reply #28 on: September 20, 2007, 09:08 PM »
New problem! :(

Ok, so here is what I am trying to do (as simply explained as possible):

I need a script to be able to check the date that a file was CREATED. I think I got this part down...
Code
FileGetTime, TimeToFix, fixschedule.txt, C
Return

But here is the problem- How do I make the script do X after Y amount of time has passed? I thought about it for a while and still don't get it. :read: Variables aren't my thing :)

ex:
Code
If %TimeToFix% > amount of time (week?)
Run myjunk.exe
else
Return

Does anyone understand? Am I just talking to the wall, and no one knows where I am coming from or what I am trying to do? Can anyone give any ideas? :tellme:

Thanks in advance,
-Brandon

lanux128

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 6,277
    • Coding Snacks
    • Volunteers/Staff
    • Gathering Badge
    • Participated in NANY Challenge Once
    • Linux User
Re: AHK Help anyone?
« Reply #29 on: September 21, 2007, 01:42 AM »
try without enclosing the variable in quotes, also you need to define formatting for TimeToFix since FileGetTime returns the date in this format: YYYYMMDDHH24MISS

Quote from: Autohotkey.chm
Note: Date-time values can be compared, added to, or subtracted from via EnvAdd and EnvSub. Also, it is best to not use greater-than or less-than to compare times unless they are both the same string length. This is because they would be compared as numbers; for example, 20040201 is always numerically less (but chronologically greater) than 200401010533. So instead use EnvSub to find out whether the amount of time between them is positive or negative.

TheQwerty

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 84
Re: AHK Help anyone?
« Reply #30 on: September 21, 2007, 11:05 AM »
You probably want something like:
Code
;Get the current time.
now := A_Now

;Subtract the creation time from current (give result in days, other options listed under EnvSub)
now -= %TimeToFix%, Days

if (now > 7) {
	Run myjunk.exe
}
return

BinderDundat

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 31
Re: AHK Help anyone?
« Reply #31 on: September 23, 2007, 05:10 PM »
Does anyone have a basic reference for ahk scripting concepts.  The help file is nice, but I have trouble doing anything more complex than creating hotkeys mainly because I really don't know basic concepts.  The wiki on ahk is really incomplete and I have a few really basic projects that I can't make happen despite trying several plausible approaches.  I don't want to have you all writing trivial scripts for me, so if you know of a useful resource - even a different language that shares concepts with ahk - I would be grateful.

jgpaiva

  • Artificial Idiocy
  • Global Moderator
  • Joined in 2006
  • *****
  • Posts: 4,727
    • Cody Award
    • Participated in NANY Challenge Once
    • Coding Snacks
    • Portugal Inhabitant
    • Linux User
Re: AHK Help anyone?
« Reply #32 on: September 23, 2007, 05:12 PM »
I think that the perfect place to start would be skrommel's 1hour software site, there are lots of scripts over there, and some of those are quite complex!

Original address: https://www.donationcoder.com/forum/index.php?topic=9320.0