Jump to content

Issues with ShellExecute() and WinMove()


Go to solution Solved by argumentum,

Recommended Posts

Posted (edited)

Good day,

First off, a "Happy New Year!" to all of you!!

In particular, to AndrewG, argumentum, Dan_555, ioa747 and pixelsearch!

Their fortitude and assistance was invaluable to the completion of the various projects that I have working this past year!

Anyhow, the following DOES NOT WORK...

; -----------------------------------------------
LaunchTextFile()
; -----------------------------------------------
Func LaunchTextFile()
    Local $MyTextFile0 = "C:\Testing\Info_Main.txt"
    ; -----------------------------------------------
    ShellExecute($MyTextFile0)
    ; -----------------
    ;Sleep(11)
    WinMove($MyTextFile0, "", 620, 300, 700, 900)
EndFunc   ;==>LaunchTextFile
; -----------------------------------------------

...whilst the following DOES WORK...

; -----------------------------------------------
LaunchTextFile()
; -----------------------------------------------
Func LaunchTextFile()
    Local $MyTextFile0 = "C:\Testing\Info_Main.txt"
    ; -----------------------------------------------
    ShellExecute($MyTextFile0)
    ; -----------------
    Sleep(11) ; <==== APPARENTLY THE "KEY"!!! Sleep(10) DOES NOT WORK!!
    WinMove($MyTextFile0, "", 620, 300, 700, 900)
EndFunc   ;==>LaunchTextFile
; -----------------------------------------------

The question is, "Why?"

The employment of "Sleep" is not mentioned in the HelpFile. If not...why not?

Am I doing something "WRONG"?

Edited by mr-es335
  • Solution
Posted
10 minutes ago, mr-es335 said:

The question is, "Why?"

Because if you need to wait for a window, you'd use WinWait()
Also, ShellExecute() does not guaranty what is going to happen. The OS will decide what to do.

Do read the help file to avoid these mishaps in your code. Because you'd become familiar with what AutoIt has to offer.
So, do the katas. Otherwise you'll be asking yourself why, why, why. ;)

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

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   1 member

×
×
  • Create New...