Jump to content
Macro Express Forums

making an opened window the 'current window'


Recommended Posts

My macro opens a window (NOT File Explorer) with a list of files (pre-selected). I need the mouse cursor to be 'in' that highlit list, so that I can apply an appropriate keystroke. The MOUSE commands available to me have 'Mouse Move', with the option to press CTRL SPACE to locate the coordinates of the desired cursor location 'relative to the current Window'. How do I ensure that the 'current window' is the one that the macro has just opened ?

Link to comment
Share on other sites

I would use the same (or similar) Macro Express instructions that rberq suggests to make the window active. But once the window is active, are you sure the mouse pointer must be positioned over the selected files? What is the next step that you want the macro to perform?

 

Do the selected files have focus when the window becomes active? You mention that the files are pre-selected; and if they are already selected, then they might have focus. And if they have focus, there may be no need to move the mouse pointer to the files.

 

If the files are already focused, you can copy them using the Macro Express copy command or outputting "text type" Ctrl + C. Or delete the files by using the "text type" command to output the Delete key. Or right-click the files by using "text type" to output the "Application" key or Shift + F10.

Link to comment
Share on other sites

2 hours ago, Sebastian42 said:

I need to press CTRL R, and that is ineffective unless the cursor is 'in' the highlit files - which are so when the MP3Tag program opens.

 

As a test, create your script up so it does everything up to the point the window becomes active. It sounds like the files you want to act on are already selected, so resist the urge to reach for the mouse. Instead, reach for the keyboard and press Ctrl + R. Does the magic happen?

 

If yes, then no need for your script to move the mouse pointer.

 

If no, then there are two options: find a way to move the mouse pointer to the files, or send keystrokes to give focus to the files.

 

The method Cory suggested, using Windows controls, could prove to be the cleanest way to accomplish what you want to do. But be forewarned that the method works better in some programs than in others, and not at all in some applications. I can get windows controls to work properly about half the time.

Link to comment
Share on other sites

I had done your suggestion and it did not work, that is why I made the post.

'find a way to move the mouse pointer to the files' I used the option as described in my first post; but it was ineffective, so I think the move was not relative to the right window; once again, that is why I made the post HOW CAN I ENSURE THAT THE WINDOW RELATIVE TO WHICH THE MOUSE COORDINATES ARE GIVEN, IS THE WINDOW OPENED BY MP3TAG ?

Link to comment
Share on other sites

I just downloaded mp3tag and am taking it for a spin.

 

So far, it appears to me that mp3tag doesn't care whether the left pane (Title, Artist, etc.) or the right pane (the list of files) has focus. In either situation pressing Ctrl + R activates the "Remove Tag" command that acts on selected files in the right pane.

 

But I've only been looking at the application for a few minutes. There may be contexts in which the hotkey doesn't work. In those cases, one of these might be more reliable, as it chooses the command from the File menu rather via hotkey:

 

Text Type (Simulate Keystrokes): <F10> // Activate menu bar
Text Type (Simulate Keystrokes): f // Choose &File
Text Type (Simulate Keystrokes): r // Choose &Remove Tag from the File menu

 

or

Text Type (Simulate Keystrokes): <ALT> // Activate menu bar
Text Type (Simulate Keystrokes): f // Choose &File
Text Type (Simulate Keystrokes): r // Choose &Remove Tag from the File menu

 

You may need to insert short delays between the steps, but probably not.

Link to comment
Share on other sites

When I tried it THIS TIME, your claim got confirmed.

I made the post because the first time I tried it did NOT happen.

Hopefully this is the last mention of the phantom problem.

 

I have now tried it and manually it works perfectly, but what fails is

<TEXT TYPE Action="0" Text="<CONTROL>r"/>

 

In your records of my thread you might find that I tried to achieve the same outcome in a much more complex way before I realised that CTRL-R  would do the trick. Then also, like now, I could not get Macro Express to operate on the highlit files. I also tried MacroRecorder and it had no difficulty at all. I have come back to the challenge because I could not find a way to complete the process using MacroRecorder - and recently I discovered that MANUALLY, CTRL-R will do all I need done.  So in a sense I am back to SQUARE ONE - what works MANUALLY, does NOT work MACROLY. Neither of your alternatives with F10 and ALT, do the trick. The error that shows in MP3Tag is "Line 1: Debug Error: Window could not be found" which echos my post : "How can I ensure that the window in which the mouse cursor co-ordinates are supplied, is the MP3Tag window ?" 

 

Edited by Sebastian42
many
Link to comment
Share on other sites

You may need delays between some steps. Start with 500 ms to one second delays. You probably don't need delays after every step, and not long delays. Many of my scripts won't work without a sprinkling of short (say 100 ms) pauses.

 

Cory's idea of using Windows controls looks viable, but only if you change one of mp3tag's settings:

 

Tools > Options > General > Show current directory in window title UNCHECKED.

 

But controls will probably need to be remade after you upgrade to a new version. The current version number appears in the title bar. Currently it's this:

 

Mp3tag v3.12

 

But captured controls include information from the window title, so not sure a macro that's based on controls will work after the release of v3.13.

Link to comment
Share on other sites

40 minutes ago, Sebastian42 said:

I referenced it as Mp3Tag v*.*

 

If you're talking about the scope of the macro, I suggest deleting the wildcards, and specify a partial match:

 

"Mp3Tag v"   (without the quotes)

 

I've struggled with wildcard searches in MEP, so I haven't tried in a long time. However, I find setting the scope to a partial match of the window title is usually good enough.

Link to comment
Share on other sites

Deleting the wildcards does not prevent the launch of MP3Tag - so that may get over the frequent version updating challenge.

Even a 5 sec delay does not enable the CTRL R process - just like initially when the macro was far more complex.

THEN, someone (you ?) concluded that Macro Express simply can not do this particular task.

That is when I looked for an alternative and found MacroRecorder which had no difficulty in applying 'the next step'.

I may have to revert to MacroRecorder.

Link to comment
Share on other sites

12 minutes ago, Sebastian42 said:

That takes us back to my original post - how to ensure that the the co-ordinates given by Macro Express are relative to the MP3Tag window (rather than another window) .

Considering the snippet of code that you posted -

1) Is the window getting activated?

2) Are you using the "exact match" or the "partial match" option of the Window Activate command?

3) Did you use the Mouse Locator tool to determine the proper coordinates?

Link to comment
Share on other sites

When I tried to recreate the problem, I noticed that no files were selected in the right pane when the program launched. So there was nothing to untag. Ctrl + R had nothing to do!

 

So I added a step that selects everything. This macro seems to work, at least as a starting point. You can copy the script below and paste it into the Macro Express Script Editor. (The first four lines show you what the instructions should look like in the Script Editor. It's preferable to copy the last four lines and paste those instead of the first four lines.)

 

You will need to edit the first line of the script. Specify the full path to mp3tag.exe.

 

Activate or Launch: Window "Mp3tag v", Program "MP3TAG.EXE", Parameters "" // Specify the path to mp3tag.exe on your computer!
Wait for Window Title: Mp3tag v
Text Type (Simulate Keystrokes): <HOME><SHIFT><END> // Go to top of list. Then select from the top to the end of the list
Text Type (Simulate Keystrokes): <CONTROL>r



  
<ACTIVATE OR LAUNCH Title="Mp3tag v" Exact_Match="FALSE" Wildcards="FALSE" Path="C:\\Users\\Testing\\Mp3tag\\MP3TAG.EXE" Mode="\x00" Default_Path="TRUE" Wait="1" Wait_For_Program="12" _COMMENT="Specify the path to mp3tag.exe on your computer!"/>
<WAIT FOR WINDOW TITLE Title="Mp3tag v" Partial="TRUE" Wildcards="FALSE" Indefinite="FALSE" Hours="0" Minutes="0" Seconds="5"/>
<TEXT TYPE Action="0" Text="<HOME><SHIFT><END>" _COMMENT="Go to top of list. Then select from the top to the end of the list"/>
<TEXT TYPE Action="0" Text="<CONTROL>r"/>

 

Link to comment
Share on other sites

Rberq - What I posted was the entire code - not merely a snippet; It SHOWS that I used the partial match. I used the Mouse Locator tool and have been asking in this forum how to ensure that the coordinates returned are relative to the MP3Tag window.

 

Acantor - Thank you - I will try it and report back.

 

When I paste the last four lines, what appears in the macro is the first four !

So I replaced your first line with my original first line - since that succeeded in opening MP3Tag

and since that did not work by itself, I introduced delays of 1 second.

 

<ACTIVATE OR LAUNCH Title="Mp3tag v  -  C:\\Captures\\" Exact_Match="FALSE" Wildcards="FALSE" Path="MP3TAG.EXE" Mode="\x00" Default_Path="TRUE" Wait="1" Wait_For_Program="12"/>
<DELAY Flags="\x01" Time="1"/>
<WAIT FOR WINDOW TITLE Title="Mp3tag v" Partial="TRUE" Wildcards="FALSE" Indefinite="FALSE" Hours="0" Minutes="0" Seconds="5"/>
<DELAY Flags="\x01" Time="1"/>
<TEXT TYPE Action="0" Text="<HOME><SHIFT><END>" _COMMENT="Go to top of list. Then select from the top to the end of the list"/>
<DELAY Flags="\x01" Time="1"/>
<TEXT TYPE Action="0" Text="<CONTROL>r"/>

 

Just as before trying your suggestion,  the macro opened MP3Tag with the files already highlit, but nothing else happened.

 

 

 

 

 

Link to comment
Share on other sites

I do not understand those three terms : shortkey, mouse event, floating menu ( lthough mouse event is self explanatory)

 

The first line of code in the macro (posted/pasted above - but I do not know how to reference it - I can't find an identifier) opens the application (MP3Tag).

Pressing CTRL R is again, a matter of code - also in that screen shot I posted - but has NOT been effective.

 

RUNNING the Macro has SO FAR been done from the TRY tool, but once the macro achieves the intended aim, would be run from a batch file - which I suppose would qualify as a 'mouse event'.

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...