Jump to content

Recommended Posts

Posted (edited)

I'm using Windows 10. I have a computer which automatically restarts once every 24 hours, and when it starts I have a BAT file in the Startup folder which automatically starts and opens about 60 programs, and in the end it opens an AutoIT script. But the AutoIT script doesn't run properly when I start it using the BAT file, and in particular these commands:

Local $Magick = 'magick convert "C:\Users\Me\Desktop\Folder\image.jpg" -crop +125+25 -crop -125-25 image1.png"'
RunWait(@ComSpec & " /c " & $Magick)

So the AutoIt script starts, it does the sleeps, it does the clicks, but it never runs these lines of code. I tried using the raw AutoIT file, I also tried compiling it as x86 and x64, and it doesn't work.

When I start the script manually, then it works fine.

---

The solution I implemented is I have my BAT file open the folder where my AutoIt script is located. Then I have the BAT file start another Autoit script, which just focuses that folder and then does a double-click to start my script that I want to run. And then it works.

I hate this solution. It feels so ugly and unnecessary 😰

What's the problem/solution here?

Thanks

Edited by Scorpys
Posted

scorpys

do the following:

1-make sure your batch File Exists in same folder as Script .au3
2-First Compile your script .au3
3-Copy your au3.exe
4-Click Start Menu
5-Type Run
6-start Run
7-Type shell:startup
8-Paste your au3.exe as Shortuct
9-that it.
10-reboot.

 

iam ِAutoit programmer.

best thing in life is to use your Brain to

Achieve

everything you want.

  • Developers
Posted
1 hour ago, ad777 said:

scorpys

do the following:

1-make sure your batch File Exists in same folder as Script .au3
2-First Compile your script .au3
3-Copy your au3.exe
4-Click Start Menu
5-Type Run
6-start Run
7-Type shell:startup
8-Paste your au3.exe as Shortuct
9-that it.
10-reboot.

 

I understand that "Many roads lead to Rome" but ....

this is a really much longer road to get there driving around the real issue which is not setting the proper Working directory! ;) 

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Posted (edited)

You are also missing a quote from the provided code, no?

Local $Magick = 'magick convert "C:\Users\Me\Desktop\Folder\image.jpg" -crop +125+25 -crop -125-25 image1.png"'
Local $Magick = 'magick convert "C:\Users\Me\Desktop\Folder\image.jpg" -crop +125+25 -crop -125-25 "image1.png"'

 

Edited by bobomb
Posted (edited)
10 hours ago, bobomb said:

You are also missing a quote from the provided code, no?

Local $Magick = 'magick convert "C:\Users\Me\Desktop\Folder\image.jpg" -crop +125+25 -crop -125-25 image1.png"'
Local $Magick = 'magick convert "C:\Users\Me\Desktop\Folder\image.jpg" -crop +125+25 -crop -125-25 "image1.png"'

 

Good catch. It's not missing one, it's more like it has an unnecessary one. The one double quote at the end is totally unnecessary, I removed it :)

 

12 hours ago, Jos said:

Set the Workingdir (parameter 2) to the proper path in the RunWait()?

Okay, and now my noob will show. I tried a few things, but I'm not understanding exactly what you mean.

I tried stuff like this, but either the CMD opens or nothing happens when I run the script.

Local $Magick = 'magick convert "C:\Users\Me\Desktop\Folder\image.jpg" -crop +125+25 -crop -125-25 image1.png'
RunWait(@ComSpec & " C:\Users\Me\Desktop\Folder " & $Magick)

I tried putting there the path where my AutoIT script is located, and the path to where my "ImageMagick" program is located. Nothing worked.

So I'm gonna google to see if I can find someone who has used this RunWait with a proper path correctly, and copy off of them. Or you can just let me know what/how I need to put there? :D

Edited by Scorpys
  • Developers
Posted (edited)
10 minutes ago, Scorpys said:

Okay, and now my noob will show.

Did you open the helpfile and check out the parameters? (press F1 on RunWait)

Quote

RunWait ( "program" [, "workingdir" [, show_flag [, opt_flag]]] )

The Workingdir is the Current directory for the shelled program, so that is where it looks for file that do not have a full path in their name.

Jos

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Posted
16 minutes ago, Jos said:

Did you open the helpfile and check out the parameters? (press F1 on RunWait)

The Workingdir is the Current directory for the shelled program, so that is where it looks for file that do not have a full path in their name.

Jos

The noob continues...

F1 just puts my computer to sleep. Not sure when you mean when you say "press F1 on RunWait".

However, I did check out this page - https://www.autoitscript.com/autoit3/docs/functions/RunWait.htm

But these pages never help me. What helps me is people sharing their problems, and I find my solutions in their problems or in the solutions given to their problems, because there you can see live examples of code.

I don't understand what you mean by shelled program...

The way I understand it, RunWait runs an external program, and @ComSpec runs the cmd, and $Magick tells it which code to run in the cmd.

This only leaves the /c, and I don't see why it's even necessary. We're already running cmd and the command in it using the above. But apparently it is. So that must be the path to the program which I'm using for my code to actually do something. That would be imagemagick. So I tried these:

Local $Magick = 'magick convert "C:\Users\Me\Desktop\Folder\image.jpg" -crop +125+25 -crop -125-25 image1.png"'
RunWait(@ComSpec & " C:\Program Files\ImageMagick-7.1.0-Q16-HDRI " & $Magick)
Local $Magick = 'magick convert "C:\Users\Me\Desktop\Folder\image.jpg" -crop +125+25 -crop -125-25 image1.png"'
RunWait(@ComSpec & " C:\Program Files\ImageMagick-7.1.0-Q16-HDRI\magick.exe " & $Magick)

Of course these didn't work. The first one just opens CMD, the second one does nothing.

And this is where I'm at now...

  • Developers
Posted (edited)

I assumed you are using SciTE as Editor to modify the source. F1 ( and it could be you need to use Fn+F1 when your Keyboard is set that way!).

When you move your cursor to the function RunWait() and then do F1, the Helpfile will be opened with an explanation of the function. ;) 

8 minutes ago, Scorpys said:

But these pages never help me. What helps me is people sharing their problems, and I find my solutions in their problems or in the solutions given to their problems, because there you can see live examples of code.

mmm ... that means you do not take the time to read and understand ...  just try to be patient and do so to really learn to program yourself!

8 minutes ago, Scorpys said:

I don't understand what you mean by shelled program...

Have you tried googling on this to see what that could mean? ;)    hint

... now start reading and only come back with a question when you have actually read my answers properly and read on the function.
I won't be replying to follow-up question unless you demonstrate you did. 

Jos

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Posted
13 minutes ago, Jos said:

I assumed you are using SciTE as Editor to modify the source. F1 ( and it could be you need to use Fn+F1 when your Keyboard is set that way!).

When you move your cursor to the function RunWait() and then do F1, the Helpfile will be opened with an explanation of the function. ;) 

mmm ... that means you do not take the time to read and understand ...  just try to be patient and do so to really learn to program yourself!

Have you tried googling on this to see what that could mean? ;)    hint

... now start reading and only come back with a question when you have actually read my answers properly and read on the function.
I won't be replying to follow-up question unless you demonstrate you did. 

Jos

Yeah, I'm not going to. I already wasted an hour and a half on this now, and more yesterday. I'll wait on a friend who understands this stuff to tell me the solution, and I'll ask on another forum to see maybe someone there can give it to me. And if all fails, I'll pay someone on Fiverr $5 bucks for the solution.

And when I get the solution, I'll understand what was needed and know it for a thousand years. And I won't have to spend 30 hours at it.

In any case, thanks for trying to help. I guess you did help, assuming that setting the workingdir in my code actually solves my problem. When I figure out how to set the workingdir, I'll post here if that helped or not, and I'll post my solution too so that anyone in the future can find it in 5 minutes versus spending 55 hours reading and learning and understanding and standing on their head :D

Cheers :)

  • Developers
Posted

Works too ...   and I am fine with that.
We are trying to help people help themselves around here, and yes, that means you have to invest some time upfront. ;) 

Good luck with your scripting. 

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Posted
1 hour ago, Jos said:

Works too ...   and I am fine with that.
We are trying to help people help themselves around here, and yes, that means you have to invest some time upfront. ;) 

Good luck with your scripting. 

Really bro? Really? Seriously? So I got the solution on another forum.

RunWait(@ComSpec & " /c " & $Magick, "C:\Users\Me\Desktop\Folder")

This is what you decided to torture me with? And I was so close, I just didn't understand... And you could have given it to me and been awesome, but you decided to be not awesome.

You see the solutions I attempted, I just didn't understand that workingdir went after the other crap. I thought the "/c" is where it should go. And you saw my simple mistake, and instead of just giving me a little push you decided to send me to school.

Ridiculous, waste of time.

Anyway you gave me the solution, it worked, but you totally abandoned me on the implelentation. It's not like you had to write 100 lines of code, all you had to do was tell me that my path doesn't go where I was putting it, but goes in the end there.

Anyway, you could've been awesome bro, but you decided to not be awesome, and you have to live with that 😅😁

  • Developers
Posted
1 minute ago, Scorpys said:

Anyway, you could've been awesome bro, but you decided to not be awesome, and you have to live with that 😅😁

... but in the end you learned something today, ;) 

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Posted
1 minute ago, Jos said:

... but in the end you learned something today, ;) 

Yeah and I could have learned it 3 hours ago, but instead I learned it 3 hours later, because of you. And you have to live with that :D😅😄

I would suggest, if someone asks what's 1+1, just tell them it's 2, don't send them to math university.

Posted
1 minute ago, Jos said:

Or tell them to go to school? ;) 

No, no no. Be a light in the world, help a brother out.

Now, if a brother asks what's 34345+6565x654654+321321-99898x852? Then you tell them to get a calculator or go to school.

But I asked what's 1+1, and you tortured me with it. How do you live with yourself?! 😅😁😅

  • Developers
Posted (edited)

 

3 minutes ago, Scorpys said:

Then you tell them to get a calculator or go to school.

Guess you finally got the proper concept...   I tell my "brother" the way to solve the question himself. This really helps him for the future. 😎

Anyway: Guess you have your answer and hopefully learned that typing all these posts takes way longer than simply looking for an answer yourself from now on, so for me this topic is done.   Enjoy! :) 

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Posted
1 minute ago, Jos said:

 

Guess you finally got the proper concept...   I tell my "brother" the way to solve the question himself. This really helps him for the future. 😎

Anyway: Guess you have your answer and hopefully learned that typing all these posts takes way longer than simply looking for an answer yourself from now on, so for me this topic is done.   Enjoy! :) 

Hopefully you learned that. I thought of the same thing, how all this typing was totally unnecessary, you could've given me the solution in your first reply in 1 sentence.

Technically I didn't find the answer. I tried, I failed. A guy on another forum gave me the answer. This is all he said:

321321.PNG.d04217a7e4408e94a7975151ab557808.PNG

See how beautiful that is? Short and sweet, and works.

Anyway I should still thank you for telling me what my solution was, and you'll be happy to know that it worked. But that said, you could've gone all the way, instead you pulled out halfway 😄😅

Posted (edited)

Yea but you didnt learn what @WorkingDir was... Use that instead of the quoted path. If you are running from the same folder.

I highly recommend going back to the help page and looking at the now working section.. It might be hard to understand without context but once u have something working you should be able to see whats going on.. @WorkingDir is a variable you can use not just a (Value) you can enter

Edited by bobomb

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
  • Recently Browsing   0 members

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