Jump to content

Question


Sly
 Share

Recommended Posts

Just started and im trying to get a program to run heres my script ...

; This is my first script

MsgBox(0, "Msn Launcher!", "Start Msn")

Run ( "msmsgs.exe", "C:\Program Files\Messenger" )

WinWaitActive ("Windows Messenger")

Whats wrong with it? Sorry I just started today I would appreciate any help.

I get this

Line 3

Error: unable to execute the external program

The system cannot find the file specified

Edited by Sly
Link to comment
Share on other sites

I remember someone else asking a similar question a while ago...

Here's the deal. The "working dir" doesn't work like that. What you need is just to take what you have in working dir, attach your file name to the end of it, and run it.

In other words: Run ("C:\Program Files\Messenger\msmsgs.exe")

That's it.

Link to comment
Share on other sites

  • Moderators

$Timer = TimerInit()
While 1
 ;Script
    Sleep(10)
    If TimerDiff($Timer) / 1000 / 60 >= 5 Then 
    SomeFuncToDoSomething()
    $Timer = TimerInit()
    EndIf
Wend

Func SomeFuncToDoSomething()
  ;Do Something
EndFunc; Return back to loop and restart timer for another 5 minutes

Edit: I didn't see you wanted to go back to the loop again: Edited code above.

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

I see Oxin8 is posting, but I'm going to start this anyway.

Funcs are really useful.

Example:

MyFunc()

; LOTS O' CODE

EndFunc

Then, you can do the While loop, call your func whenever, exit the loop, call your func some more, etc etc. As long as you don't exit the script, you can go back to that func (if it's around the loop then it'll go back into the loop) as often as you need.

Link to comment
Share on other sites

I can think of a few ways to do this.....

While 1
For $i = 1 to 30000;300000ms = 5 min
;your stuff
sleep(10); any sleep time. just make sure sleeptime * endnumber on for loop = 300000ms
Next
;stuff to do every 5 minute
WEnd

AdlibEnable ( "stufftodo", 300000)
While 1
;your stuff
WEnd

Func stufftodo()
;stuff for every 5 min
EndFunc

Dim $i
$i = 1
While 1
$i = $i + 1
;your stuff
If $i = 30000 Then
 ;stuff for every 5 min
  $i = 1
EndIf
Sleep(10); same time*loop count concept as first one
WEnd

lol.... greenmachine...

Link to comment
Share on other sites

  • Moderators

I can think of a few ways to do this.....

While 1
For $i = 1 to 30000;300000ms = 5 min
;your stuff
sleep(10); any sleep time. just make sure sleeptime * endnumber on for loop = 300000ms
Next
;stuff to do every 5 minute
WEnd

AdlibEnable ( "stufftodo", 300000)
While 1
;your stuff
WEnd

Func stufftodo()
;stuff for every 5 min
EndFunc

Dim $i
$i = 1
While 1
$i = $i + 1
;your stuff
If $i = 30000 Then
;stuff for every 5 min
  $i = 1
EndIf
Sleep(10); same time*loop count concept as first one
WEnd

lol.... greenmachine...

None of those are correct for time functions. I can go through 300,000 loops in less than a minute on my computer.

Edit: The AdlibEnable() will work, I totally missed that one.

Run this to see how long it takes yours... took mine 46.82 seconds to do 300,000 loops:

$timer = TimerInit()
Local $i
While 1
    $i = $i + 1
    ToolTip($i, 0, 0)
    If $i = 300000 Then ExitLoop
WEnd
MsgBox(0, TimerDiff($timer) / 1000, TimerDiff($timer) / 1000 / 60)
This will show you what I mean. Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

I think you failed to notice the 'sleep's I had written in... So i did some testing and my 2 loop examples would have taken long that the wanted wait time. The longer the 'sleep' time is, the more accurate my examples work. I'll definately start using the timer thing from now on though but don't be so quick to assume I was ignorant enough to simply loop 300000 times...

Link to comment
Share on other sites

  • Moderators

I think you failed to notice the 'sleep's I had written in... So i did some testing and my 2 loop examples would have taken long that the wanted wait time. The longer the 'sleep' time is, the more accurate my examples work. I'll definately start using the timer thing from now on though but don't be so quick to assume I was ignorant enough to simply loop 300000 times...

LOL, would never call you ignorant, ignorance would be someone telling you that your example has logic flaws, and you ignoring it and continueing to keep doing what you do.

I'm in no way an expert and don't mean to come off snub as I sometimes do, but if you read my edit, as I said, your AdlibEnable() example would work also, and actually would be less code than my TimerInit() option.

Edit:**Grammar

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

  • Moderators

Point is, the three examples I gave work, just less efficiently and accurately than others.

Ok man... I'm not posting the above or below to get in a pissing contest.

1. I said what I said about the code you posted because... you couldn't make examples one and three into a UDF because of different computer speeds. So yes, they time out after a certain period of time, but you have to sit there and figure out how long that time is. Which we all use AutoIt for automation and making things as lazy as possible :lmao:

2. Example 2: AdlibEnable() is a wonderful solution.

3. It was my mistake for not looking that you had a Sleep(10) there.

I post things all the time that are inefficient and someone cleans it up behind me, but to your defense, Most do it more tactfully that what I came across, I meant no harm nor foul and apologize if it came off rude or disconcerning.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

MouseClick ("Mouse1" "X: 512 Y: 377" "1" "0")

1. You need commas between parameters.

2. Numbers don't go in quotes unless they're supposed to be strings. In this case, they aren't.

3. I don't know if Mouse1 is the actual button name... but "Primary" definitely works.

4. No need to say x: and y: in the x and y parameters.

5. It should end up like this: MouseClick ("primary", 512, 377, 1, 0)

6. Did you try the helpfile?

Edited by greenmachine
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...