dimanche 22 octobre 2017

How to perform a mouse click with the keyboard in a cross platform way?

This question is for programmers using Microsoft's Hotmail service.

In the website hotmail.com there is a section with messages you already deleted, so to recover or fully delete them. You can access that section this way:

  1. Go to "Deleted items".
  2. Go to "recover deleted items".
  3. A window will be opened with deleted conversations.
  4. Near to each conversation there will be a checkbox (after mouseover).

In this section, there are multiple pseudo checkboxes that I couldn't target with a script containing click() and/or setAttribute():

(()=>{
    document.querySelectorAll('button span').forEach((e)=>{
        e.click()
    });
})();

The pseudo checkboxes are not input[type="checkbox"] elements of course (as you most probably have seen, they are span elements).

The Hotmail webapp is based on custom technology that makes it entirely unnatural in compared to many other websites and as of the moment I don't have enough knowledge in JavaScript, or the spare time to keep investigating this in a serious manner (we already had long discussions regarding it in this SOF QA session). I'm not even sure that HTML has anything to with this.

A solution to check all pseudo check all pseudo checkboxes was correct but isn't enough to make the checked checkboxes to be considered "checked" by their check validation mechanism, hence, the messages cannot be recovered or deleted).


Alternative approach:

It seems to me that JavaScript isn't the correct solution for this problem of checking pseudo checkboxes that wouldn't otherwise be selected in common JavaScript methods and I should take another approach from the outside.

My thought:

I need a way to make a mouse click anywhere on the screen whether if I do computing from Windows10, Linux (Ubuntu), or macOS. Is there any such "cross platform" way to initiate a mouse click or must I use AHk in Windows, or any other "local" scripting language for each different operating system?

My final aim is to have a script that starts when I press a certain keyboard key and does this loop (I will place the mouse cursor on a pseudo checkbox just before starting the loop):

  1. Triggers a left mouse click event, wherever my mouse cursor is aimed at the moment.
  2. Goes down say 30 pixels, in this case, to the next pseudo checkbox.

Notes:

  1. Given the Operating system I use most frequently is Windows10, and the unlikelihood for an efficient crossplatform solution, I guess the best solution I Can have, is in AutoHotkey.

  2. If you have a better approach to cope with this, please publish an answer.




Aucun commentaire:

Enregistrer un commentaire