Jump to content

ShellExecute() and WinMove()


Go to solution Solved by mr-es335,

Recommended Posts

Good day,
I hope that the day finds you well!

I thought that I had been employing specific scripts for some time - all of which "appeared" to be working as expected.

And yet today, I am having "issues" with these very same scripts.

So, I have a two-part query....

Part A
1) Create a folder entitled "Me" which is located in the root of Drive C.
2) Within this "Me" folder, create a text file, also entitled "Me".
3) Within the "Me" folder, create a subfolder entitled "You".
4) Within this "You" folder, create a text file, entitled "You".
5) Now, create a folder entitled "Scripts" - and which is located in the root of Drive C.
6) Within this Scripts folder, create three scripts [...see attachment...]:
a) _LaunchMe
b) _ExitMeLaunchYou
c) _ExitYou
7) Launch: Me.au3
* Observations: The "Me" folder launches on the left - with the "Me.txt" launching on the right.
8] Launch: _ExitMeLaunchYou.au3
* Observations:
a) The "Me.txt" exits - immediately followed by the "Me" folder.
b) The "You" folder launches on the left - with the ""You.txt" launching on the right.
9) Finally, launch: _ExitYou.au3

So far...so good!!

Part B
Part  is similar to Part A - the only difference being that the "Scripts" folder has been moved inside the "Me" folder.

My questions then is, "Should Part B function in a similar manner as that of Part A?" "And if not...why not?"

Any assistance in this matter would be greatly appreciated!

PS: I have attached a ZIP file of the various folders and scripts for your perusal.

Sample.zip

Edited by mr-es335
Link to comment
Share on other sites

@mr-es335 Hi
The issue you're facing can happen no matter where the Script folder is placed (tested). Please have a look at this pic :

severalC-me1.png.9fe6a21676d422907b32e85d39f5dfa3.png

It shows 4 windows whose title start with "C:\Me"
1) First one is the one you want to close, created by the script "_LaunchMe.au3")

2) The three other windows (respectively Windows Explorer, XYplorer, Scite-Lite) point on purpose to folders (or file for Scite-Lite) whose title starts with "C:\Me"

So don't be surprised, when you run the 2nd script ("_ExitMeLaunchYou.au3") and you see one of these 4 windows suddenly closing when this line is encountered :

WinClose($_prev_ftitle) ; it will close one of the four windows whose title starts with "C:\Me" but which one ?

One solution could be to use this line and changes the default value, from...

Opt("WinTitleMatchMode", 1) ;1=start (default), 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase

...to 3 (exact match)

Opt("WinTitleMatchMode", 3)

Results would be a bit better but not accurate at all, in case the system finds 2 windows having exactly the same title "C:\Me", for example :

severalC-me2.png.fcee98aefcee51c3c6717c6e8c9ee8c3.png

1) First window is Windows Explorer pointing on purpose to the folder "C:\Me"

2) Second window is the one you want to close (created by the script "_LaunchMe.au3")

As you can see, you'll have 50% of chances to close the right one, even with Opt("WinTitleMatchMode", 3)

The only way to make sure you close the right window is to close it using its handle (titles are not unique, handles are). Now you got a bit of work to do, your goal should be to retrieve the correct handle

Good luck :bye:

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...