Jump to content

Windows Title Properties


Go to solution Solved by mr-es335,

Recommended Posts

Posted

Good day,

I use metapad as my default text editor.

There is an apparent issue with the paths when comparing Notepad wit metapad, as shown below:

Using Notepad, the Windows title property shows: Test - Notepad
Using metapad, the Windows title property shows: E:\Desktop\Test.txt - metapad

Any ideas as to why the path/title is much linger with metapad?

Thanks for any assistance one may provide.

Posted

Andriek,

; -----------------------------------------------
ShellExecute("E:\Desktop\Me.txt")
$hWinMetapad=WinWait("E:\Desktop\Me.txt - metapad")
WinMove($hWinMetapad, "", 1020, 100, 550, 650)
; -----------------------------------------------

So, in the above, the path to the 2nd line to the text file changes from "[E:\Desktop\Me.txt" to "Me.txt - metapad" - or vice-versa.

Hope this makes sense?

Posted (edited)

No, it doesn't make any sense. Yes, the title it changes, so what? What's the problem?

Use WinSetTitle() if you want a specific title.

Or something like this:

AutoItSetOption('WinTitleMatchMode', 2)

$Path = 'E:\Desktop\'
$Filename = 'Me.txt'
ShellExecute($Path & $Filename)
WinWait($Filename)
WinMove($Filename, '', 1020, 100, 550, 650)

 

Edited by Andreik
Posted (edited)

Adriek,

On my "test system" [WIN7 PRO] - the above script you provided works as noted. However, on my "non-test system" [WIN10 LTSC], the script opens the text but does not position the text.

Is there any way to ensure that the "called " text/folder is positioned where it should?

Edited by mr-es335
Posted

In your first post you said that Notepad does report the filename but not the extension in the title.

If that is true than that explains why the winwait/winmove fail because you are searching for name including extension.

There are different versions of notepad on different versions of windows  and even if the windows version is the same there can be different versions of notepad installed.

Shellexecute returns the pid of the started program.

You can use this pid to find the window handle(s) created by this process.

If there is just one window that will be the one you need. If there are more than you will have to select the correct one yourself.

Now you can use winwait/winmove with the window handle as parameter and these will function as expected.

.

#Include <Array.au3>
#Include <WinAPIEx.au3>

Opt('MustDeclareVars', 1)

AutoItSetOption('WinTitleMatchMode', 2)

Local $Path = 'E:\Desktop\'
Local $Filename = 'Me.txt'
Local $iPid = ShellExecute($Path & $Filename)

Global $aData = _WinAPI_EnumProcessWindows($iPid)

If IsArray($aData) Then
   Local $hWnd = $aData[1][0]
   WinWait($hWnd)
   WinMove($hWnd, '', 1020, 100, 550, 650)
   _ArrayDisplay($aData, '_WinAPI_EnumProcessWindows')
EndIf

 

Posted

With a file without extension ShellExecute will fail, because it needs the extension to determine which program to start.

You can however change your code to use Run and start the program (editor) of your choice with your filename without extension.

Run will also return the pid from the started program so the remaining code will be the same.

 

  • Solution
Posted

Good day,

I was able to resolve the issue by ensuring that a delineation exited between what ShellExecute  was requiring and what WinMove was requiring.

All is working as it should!

Thanks to all who responded...appreciated!

 

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