terrypin Posted September 20, 2016 Report Share Posted September 20, 2016 With no window already open, I would expect this command to open Notepad, but it doesn't. Activate or Launch: Window "Notepad", Program "notepad.exe", Parameters "" <ACTIVATE OR LAUNCH Title="Notepad" Exact_Match="FALSE" Wildcards="FALSE" Path="C:\\Windows\\notepad.exe" Mode="\x00" Default_Path="TRUE" Wait="1" Wait_For_Program="12"/> However this does: Activate or Launch: Window "Untitled - Notepad", Program "notepad.exe", Parameters "" <ACTIVATE OR LAUNCH Title="Untitled - Notepad" Exact_Match="FALSE" Wildcards="FALSE" Path="C:\\Windows\\notepad.exe" Mode="\x00" Default_Path="TRUE" Wait="1" Wait_For_Program="12"/> Both are set to 'Partial' and both contain the string 'Notepad', so I don't see why the first doesn't work? -- Terry, East Grinstead, UK Quote Link to comment Share on other sites More sharing options...
Cory Posted September 20, 2016 Report Share Posted September 20, 2016 Odd. Do you have any invisible programs running that have the word "Notepad" in them? Quote Link to comment Share on other sites More sharing options...
Cory Posted September 20, 2016 Report Share Posted September 20, 2016 I created a macro that has a message box with a condition of if a window exists with a partial name of "Notepad" and it tests true. I can't find it but it's there. I think you might have the same issue. <IF WINDOW Option="\x01" Title="Notepad" Partial="TRUE" Wildcards="FALSE"/> <MESSAGEBOX Caption="Yup" Message="It exists" Icon="0"/> <END IF/> Quote Link to comment Share on other sites More sharing options...
Cory Posted September 20, 2016 Report Share Posted September 20, 2016 In my case I had my web browser open to this post and it has "Notepad" in the title so it was switching to the web browser and not launching Notepad. I closed this web browser and your first command ran fine. I suggest you write a macro with a Repeat With Windows (all) and a condition of If Variable Contains to look for any instances of a window that contains "Notepad" and display them in a message box. I bet you have something running with Notepad in the title. Quote Link to comment Share on other sites More sharing options...
terrypin Posted September 20, 2016 Author Report Share Posted September 20, 2016 Neat idea! I was just about to reply to your first answer, reporting that I could find nothing containing 'Notepad' or 'notepad', including in the scores (hundreds?) listed under Hidden. Then I tried your macro. But I only get existence confirmed if I have this thread open in my browser! Maybe that's the case for you too? -- Terry, East Grinstead, UK Quote Link to comment Share on other sites More sharing options...
terrypin Posted September 20, 2016 Author Report Share Posted September 20, 2016 Crossed in the post! Will explore more, including that suggestion, but as mentioned MX Pro could not see any. Quote Link to comment Share on other sites More sharing options...
terrypin Posted September 20, 2016 Author Report Share Posted September 20, 2016 Nope, that Repeat macro confirmed the only instance was this thread. I closed it (and even Firefox itself) and retried the commandActivate or Launch: Window "Notepad", Program "notepad.exe", Parameters "" <ACTIVATE OR LAUNCH Title="Notepad" Exact_Match="FALSE" Wildcards="FALSE" Path="C:\\Windows\\notepad.exe" Mode="\x00" Default_Path="TRUE" Wait="1" Wait_For_Program="12"/> But it still failed to open Quote Link to comment Share on other sites More sharing options...
Cory Posted September 21, 2016 Report Share Posted September 21, 2016 I don't know what to tell you then It should work and in fact does work for me. But I'll keep trying to think of anything else to try. Quote Link to comment Share on other sites More sharing options...
Look_Up Posted September 22, 2016 Report Share Posted September 22, 2016 Hello Terri, please try this peace of code to find out which window is open, hidden or visible <COMMENT Value="Initialing"/> <VARIABLE SET STRING Option="\x00" Destination="%text_variable2[1]%" Value="--------------------------------------------------------------------------------------" NoEmbeddedVars="FALSE"/> <VARIABLE SET STRING Option="\x00" Destination="%text_variable2[2]%" Value="VISIBLE WINDOW" NoEmbeddedVars="FALSE"/> <VARIABLE SET STRING Option="\x00" Destination="%text_variable2[3]%" Value="HIDDEN WINDOW" NoEmbeddedVars="FALSE"/> <COMMENT Value="Write \"visible window\" into textfile"/> <TEXT BOX DISPLAY Title="Please wait" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1031{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}{\\f1\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs16 Please wait while loading and writing Window list...\\f1 \r\n\\par }\r\n" Left="center" Top="366" Width="294" Height="94" Monitor="0" OnTop="FALSE" Keep_Focus="TRUE" Mode="\x02" Delay="0"/> <VARIABLE MODIFY STRING Option="\x12" Destination="%text_variable2[1]%" Filename="%temp%\\find_window.txt" Strip="TRUE" NoEmbeddedVars="FALSE"/> <VARIABLE MODIFY STRING Option="\x12" Destination="%text_variable2[2]%" Filename="%temp%\\find_window.txt" Strip="TRUE" NoEmbeddedVars="FALSE"/> <VARIABLE MODIFY STRING Option="\x12" Destination="%text_variable2[1]%" Filename="%temp%\\find_window.txt" Strip="TRUE" NoEmbeddedVars="FALSE"/> <COMMENT Value="Write all 'visible window' names into textfile"/> <REPEAT WITH WINDOWS ToRetrieve="\x01" SortOrder="\x01" Destination="%text_variable%"/> <DELAY Flags="\x02" Time="50"/> <VARIABLE MODIFY STRING Option="\x12" Destination="%text_variable%" Filename="%temp%\\find_window.txt" Strip="TRUE" NoEmbeddedVars="FALSE"/> <END REPEAT/> <COMMENT Value="Write \"hidden window\" into textfile"/> <VARIABLE MODIFY STRING Option="\x12" Destination="%text_variable2[1]%" Filename="%temp%\\find_window.txt" Strip="TRUE" NoEmbeddedVars="FALSE"/> <VARIABLE MODIFY STRING Option="\x12" Destination="%text_variable2[3]%" Filename="%temp%\\find_window.txt" Strip="TRUE" NoEmbeddedVars="FALSE"/> <VARIABLE MODIFY STRING Option="\x12" Destination="%text_variable2[1]%" Filename="%temp%\\find_window.txt" Strip="TRUE" NoEmbeddedVars="FALSE"/> <COMMENT Value="Write all 'hidden window' names into textfile"/> <REPEAT WITH WINDOWS ToRetrieve="\x02" SortOrder="\x01" Destination="%text_variable%"/> <DELAY Flags="\x02" Time="50"/> <VARIABLE MODIFY STRING Option="\x12" Destination="%text_variable%" Filename="%temp%\\find_window.txt" Strip="TRUE" NoEmbeddedVars="FALSE"/> <END REPEAT/> <TEXT BOX CLOSE Header="Please wait"/> <IF MESSAGE Caption="Ready. Open file?" Message="Hey. I'm ready to list all visible and hidden window. The textfile is in \"temp\\find_window.txt\". Do you want open it ?" BtnMode="\x00" Default="TRUE" Left="Center" Top="Center" Monitor="0" Delay="0"/> <SHOW DIALOG WINDOW Dialog="Run Programs"/> <DELAY Flags="\x01" Time="1"/> <TEXT TYPE Action="0" Text="%temp%\\find_window.txt<ENTER>"/> <ELSE/> <MACRO STOP/> <END IF/> This code create a file find_window.txt into %temp% folder. After that he write all window title into this text file. When it's all done he want ask you to open this text file. With Contr.+F you can search for "notepad" window title. Good luck. Look_Up Quote Link to comment Share on other sites More sharing options...
terrypin Posted September 22, 2016 Author Report Share Posted September 22, 2016 Thanks Look-Up, but that gave the same result as my much simpler macro: Repeat with Windows: All Windows: Store in variable %tWindows% If Variable %tWindows% Contains "Notepad" Text Box Display: This is a window containing Notepad End IfEnd Repeat <REPEAT WITH WINDOWS ToRetrieve="\x00" SortOrder="\x00" Destination="%tWindows%"/> <IF VARIABLE Variable="%tWindows%" Condition="\x06" Value="Notepad" IgnoreCase="FALSE"/> <TEXT BOX DISPLAY Title="This is a window containing Notepad" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang2057{\\fonttbl{\\f0\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs16 %tWindows%\r\n\\par }\r\n" Left="Center" Top="Center" Width="278" Height="200" Monitor="0" OnTop="TRUE" Keep_Focus="TRUE" Mode="\x00" Delay="0"/> <END IF/> <END REPEAT/> However, your macro will certainly be useful to provide a neat presentation of all windows for visual browsing. BTW, I'm curious about the way you've named your variables? Why not just names like tVisible, tHidden, tUnderline, etc? Or even T[1], T[2], T[3] to save typing? @Cory: There must be some other explanation for that bizarre behaviour, not a hidden window. Or at least not one that MX Pro can find. I'll just use '-Notepad' in future. Incidentallly, I currently see no fewer than 252 windows listed! -- Terry, East Grinstead, UK Quote Link to comment Share on other sites More sharing options...
Look_Up Posted September 22, 2016 Report Share Posted September 22, 2016 [...] BTW, I'm curious about the way you've named your variables? Why not just names like tVisible, tHidden, tUnderline, etc? Or even T[1], T[2], T[3] to save typing? [...] --Terry, East Grinstead, UK Hey Terry. Do you try to restart you MEP ? Sometime MEP behave strange and after a restart it works fine. This is my (crazy) way to write variables names ;-) In huge and complex macro, real short macros variable names are not good to identify and so i use long and good readable var. Wait a second: i try to open notepad with MEP. Stand by Quote Link to comment Share on other sites More sharing options...
Look_Up Posted September 22, 2016 Report Share Posted September 22, 2016 The "Activate or Launch" command first looking for a window with the same name. If he find one he will activate it (and don't start notepad.exe) <LAUNCH PROGRAM AND ACTIVATE WINDOW Title="Untitled" Exact_Match="FALSE" Wildcards="FALSE" Path="C:\\Windows\\notepad.exe" Mode="\x00" Default_Path="TRUE" Wait="1" Wait_For_Program="12"/> Its better to use the command "launch program and activate window" and use 'Untitled' as window name. <IF PROGRAM Option="\x01" Program="NOTEPAD.EXE"/> <WINDOW ACTIVATE Title="Untitled" Exact_Match="FALSE" Wildcards="FALSE" _IGNORE="0x0006"/> <ELSE/> <LAUNCH PROGRAM AND ACTIVATE WINDOW Title="Untitled" Exact_Match="FALSE" Wildcards="FALSE" Path="C:\\Windows\\notepad.exe" Mode="\x00" Default_Path="TRUE" Wait="1" Wait_For_Program="12"/> <END IF/> Look_Up Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.