Home | Blog | Software | Reviews and Features | Forum | Help | Donate | About us
topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • September 03, 2015, 10:53:18 PM
  • Proudly celebrating 10 years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Last post Author Topic: AHK Help anyone?  (Read 10047 times)

ak_

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 223
    • View Profile
    • wopah
    • Donate to Member
Re: Request for AHK help...I feel so dumb...
« Reply #25 on: August 16, 2007, 05:27:44 AM »
Here's how i would do it :
Code: [Select]
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, 05:32:07 AM by ak_ »

wreckedcarzz

  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 1,623
    • View Profile
    • Read more about this member.
    • Donate to Member
Re: Request for AHK help...I feel so dumb...
« Reply #26 on: August 16, 2007, 08:38:50 PM »
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
    • View Profile
    • wopah
    • Donate to Member
Re: Request for AHK help...I feel so dumb...
« Reply #27 on: August 16, 2007, 10:56:38 PM »
You're welcome :)

By the way, i found out that this has the same result and takes less code :
Code: [Select]
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

  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 1,623
    • View Profile
    • Read more about this member.
    • Donate to Member
Re: AHK Help anyone?
« Reply #28 on: September 20, 2007, 04:08:23 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: [Select]
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: [Select]
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,219
    • View Profile
    • Coding Snacks by Lanux128
    • Donate to Member
Re: AHK Help anyone?
« Reply #29 on: September 20, 2007, 08:42:01 PM »
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
  • **
  • default avatar
  • Posts: 84
    • View Profile
    • Donate to Member
Re: AHK Help anyone?
« Reply #30 on: September 21, 2007, 06:05:44 AM »
You probably want something like:
Code: [Select]
;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
  • **
  • default avatar
  • Posts: 31
    • View Profile
    • Donate to Member
Re: AHK Help anyone?
« Reply #31 on: September 23, 2007, 12:10:46 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

  • Global Moderator
  • Joined in 2006
  • *****
  • Posts: 4,727
    • View Profile
    • Read more about this member.
    • Donate to Member
Re: AHK Help anyone?
« Reply #32 on: September 23, 2007, 12:12:56 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!