Jump to content
Macro Express Forums

Move mouse to icon on desktop


Recommended Posts

Hello all,

 

I wanted to know if ME Pro can search the desktop folder for a specific file(using Repeat) and once it comes up with the file, drag the mouse to the file, click once and drag the file(unopened) to another area of the screen?

 

I have been trying a few things and all have failed me. I am probably missing something.

 

Here is the sequence:

 

A)Directory command senses added file to Desktop folder

B)Repeat through the folder to find the newest file

C)???? This is the part that I cannot figure out??? How can you drag the mouse to the file?

D)Single left click and hold down mouse

E)Keep the left mouse button down

f)Provide coordinates to where the mouse should go(while the left mouse is held down)

g)Move mouse with file to coordinate

h)Release mouse

 

Pat

Link to comment
Share on other sites

If this can be done, you may, ironically, need a less mouse-centric approach. Once you know (or determine) the name of a recently created object on the desktop...

 

1. Assign it to a text variable -- let's call it %target%.

 

2. Put focus on the desktop -- the most reliable (non-programmatic) way I know to do this is to send this sequence of keys: (You may need to add delays between the steps)

 

Text Type <ESC> // If "Start" menu is open, close it

Text Type <WIN> // Open "Start" menu

Text Type <ESC> // Close "Start" menu, but leave it focused

Text Type <SHIFT><TAB> // Move focus to desktop

 

3. "Type out" that name to give focus the new object:

 

Text Type %target% // Incremental search for item on desktop

 

Note that this technique can fail if there is another object that starts with the same characters. For example, if the target is called "Hello 123" and there is already something called "Hello 1234," the latter may be found instead of the former. Under most circumstances, this will not be a problem.

 

4. Move the mouse cursor to the target. You will need a hack to do this. Unfortunately, this will not work:

 

Mouse Move: To the Text Cursor Position

 

But if you begin to rename the object, the approach will work. You may need to add delays to increase reliability:

 

Text Type <F2> // Windows keyboard command to rename an object

Mouse Move: To the Text Cursor Position

Text Type <ESC> // Cancel the rename operation

 

I hope this gets you started.

Link to comment
Share on other sites

Very clever, Alan!

 

I think the problem of finding the wrong icon, among similarly-named ones, can be resolved also by the technique of beginning to rename the found item:

 

Repeat Start

Text Type %target% // Incremental search for item on desktop

Text Type <F2> // Windows keyboard command to rename an object

Copy to clipboard

Compare the copied name to %target%

If equal

exit from repeat loop

else Text Type <ESC> // Cancel the rename operation

End If

Repeat End

Mouse Move: To the Text Cursor Position

Text Type <ESC> // Cancel the rename operation

Link to comment
Share on other sites

Nice addition, rberg!

 

I think it is possible to script this with Macro Express, but it may take work to make it reliable. And it may not work perfectly. The script might fail, for example, if certain system settings are changed. My hunch is that the dragging aspect would work best if the desktop is set to "Auto Arrange Icons." Not sure what would happen if the desktop becomes overpopulated.

 

Sometimes, script work under certain conditions. That's OK, as long as the user understands the limits. It's not easy to develop complex macros that are 100% reliable. The "ideal" macro is reliable, robust, fast, portable, easy to use, and easy to remember. Most scripts require trade-offs.

Link to comment
Share on other sites

Hi, what exactly are you planning to do with the file? Are you moving/copying to another folder? Launching it?

 

If so, there is a more straightforward way.

 

The Desktop is merely another folder in your system. It is usually located in C:\Users\"Your Username"\Desktop

 

Once you've figured out the exact path for your Desktop, You can use commands like If File Exists to check if the file is present. After that, there are the File/Folders commands that allow you to move, copy, delete, rename, etc.

 

If you need to open the file using a specific program, you can try the Program Launch command. Most programs will accept a filename as a parameter, e.g.

 

Program/Path name:

C:\Program Files\IrfanView\i_view32.exe

 

Program Parameters:

"C:\Users\Your Username\Desktop\Image file you want to open.jpg"

 

e.g. 2:

 

Program/Path name:

notepad.exe

 

Program Parameters:

"C:\Users\Your Username\Desktop\Text file you want to open.txt"

 

No mousing needed ;-)

 

Hello all,

 

I wanted to know if ME Pro can search the desktop folder for a specific file(using Repeat) and once it comes up with the file, drag the mouse to the file, click once and drag the file(unopened) to another area of the screen?

 

I have been trying a few things and all have failed me. I am probably missing something.

 

Here is the sequence:

 

A)Directory command senses added file to Desktop folder

B)Repeat through the folder to find the newest file

C)???? This is the part that I cannot figure out??? How can you drag the mouse to the file?

D)Single left click and hold down mouse

E)Keep the left mouse button down

f)Provide coordinates to where the mouse should go(while the left mouse is held down)

g)Move mouse with file to coordinate

h)Release mouse

 

Pat

Link to comment
Share on other sites

I don't understand Alan. How are you going ot know the coordinates of an icon on your desktop?

 

1. Select a desktop icon.

2. Press F2 to rename.

3. Use MEP to move the mouse cursor to the text cursor position.

4. Get the coordinates relative to the screen.

 

The coordinates of the field are not exactly the coordinates of the icon, but nudging the cursor upwards a little (or hunting for icon-specific pixel colours) should take you to the icon itself. Perhaps the position found in step 4, above, is close enough to do what the OP wants to do.

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

×
×
  • Create New...