mr-es335 Posted September 10, 2023 Posted September 10, 2023 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. mr-es335 Sentinel Music Studios
Andreik Posted September 10, 2023 Posted September 10, 2023 Really? Because every app show whatever it wants in the title. Ask the developers why is that.
mr-es335 Posted September 11, 2023 Author Posted September 11, 2023 Andreik, Not necessarily so! I am having major issues with "titles" - changing from [filename.txt] to [path][filename.txt] - as noted above... mr-es335 Sentinel Music Studios
Andreik Posted September 11, 2023 Posted September 11, 2023 And what exactly is your question? Until now you didn't said anything AutoIt related.
mr-es335 Posted September 11, 2023 Author Posted September 11, 2023 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? mr-es335 Sentinel Music Studios
Andreik Posted September 11, 2023 Posted September 11, 2023 (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 September 11, 2023 by Andreik
mr-es335 Posted September 11, 2023 Author Posted September 11, 2023 (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 September 11, 2023 by mr-es335 mr-es335 Sentinel Music Studios
OJBakker Posted September 11, 2023 Posted September 11, 2023 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
mr-es335 Posted September 11, 2023 Author Posted September 11, 2023 (edited) OJBakker, Thanks for this... How would this work with [E:\Desktop\Me] and [E:\Desktop\Me.txt] Edited September 11, 2023 by mr-es335 mr-es335 Sentinel Music Studios
OJBakker Posted September 11, 2023 Posted September 11, 2023 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 mr-es335 Posted September 12, 2023 Author Solution Posted September 12, 2023 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! mr-es335 Sentinel Music Studios
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now