Sign in to follow this  
Followers 0
Sly

Question

21 posts in this topic

#1 ·  Posted (edited)

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

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

you need to write is like:

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

From the help file:

Run ( "filename" [, "workingdir" [, flag[, standard_i/o_flag]]])

"working directory" isn't the same thing as "path of the executable".

LD

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Thanks for the fast help. It worked!

Edited by Sly

Share this post


Link to post
Share on other sites

And greenmachine beats out LondonNDIB by a solid minute! Good race you two!

I may have won this race, but you have 5 of the 6 most recent posts. That's a little more impressive.

Share this post


Link to post
Share on other sites

Another question if my script is going for a while and looping fine. What would i use to have it stop looping after 5 mins (i know what i want to to do in between) and then say restart looping?

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

$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

[center]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.[/center]

Share this post


Link to post
Share on other sites

Thanks alot i feel like a noob :lmao:

Share this post


Link to post
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.

Share this post


Link to post
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...

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

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

[center]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.[/center]

Share this post


Link to post
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...

Share this post


Link to post
Share on other sites

#15 ·  Posted (edited)

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

[center]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.[/center]

Share this post


Link to post
Share on other sites

#16 ·  Posted (edited)

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

EDIT: It's 2:32 am here. I'm probably just being cranky and should go to sleep. Sorry Smoke_N.

Edited by Oxin8

Share this post


Link to post
Share on other sites

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.


[center]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.[/center]

Share this post


Link to post
Share on other sites

#18 ·  Posted (edited)

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

That is not working and then I try it scites way and I get this

Its in my attachment any help is cool ive been toying with it for a hour

Mouse_click.bmp

Edited by Sly

Share this post


Link to post
Share on other sites

#19 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

Next time ill read some more through the help file.

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