Jump to content
Macro Express Forums

rberq

Members
  • Posts

    1,201
  • Joined

  • Last visited

  • Days Won

    61

Posts posted by rberq

  1. 11 hours ago, acantor said:

    I find that pressing "Alt+spacebar" followed by "c" closes almost all applications

    That's what my "kill" macro does -- courtesy of a previous post where you pointed out that method, thank you.  But I find that to be a clumsy key combination to press.  Maybe like the piano it would get easier with practice.  It's also pretty simple logic in a macro to locate the upper right corner of a window and click the X.  So the problem is not how to kill the application; the problem is how to get the macro to run in the first place when Windows blocks hotkey use.  Since Windows apparently does NOT block Macro Express from seeing the mouse, and since I often am using the mouse anyway, making use of it's movements is convenient.  It's a bit like flicking an app away on my wife's iPad or on the Android phone.  I wonder if there are others distinctive movements I could use for other functions ....

  2. OK, nothing earthshaking here, but this project was kind of fun.  I have a hot key macro that closes whatever application/window is focused, by entering keystrokes <ALTD><SPACE>c<ALTU>.  If Firefox or Chrome is focused with one or more tabs open, it types <CTRLD>w<CTRLU> instead, to close the current tab.  Anyhow, I was frustrated because many Windows 10 applications block ME from seeing the hot key, so the "close application" macro doesn't run when I would like it to.  

     

    The macro below runs in a continuous loop, sampling the mouse location frequently.  If I flick the mouse to the right, then back to the left, the macro recognizes that pattern and runs the "close application" macro.  Seems to work fine in Windows 10 screens where hotkeys are blocked.  The macro is handier than I thought it would be -- I seldom reach for my hot key any more.  I'm still tinkering with the timing and distance of the mouse moves, to avoid accidentally reacting to normal mouse movements.  Also there are a few other macros that have been caught because they themselves do mouse movements that fit the pattern -- still weeding out a few of those.  The macro running continuously uses about six percent of the CPU, but the darned processor is so fast it's just loafing most of the time anyway.  

     

    // Track mouse, cancel application for rapid movement left to right and back
    // This macro is intended to run virtually all the time, in a continuous loop
    //  
    Variable Set Integer %movement% to 150 // Set minimum distance that qualifies as a mouse movement

    //  
    Variable Set String %repeater% to "0"
    Repeat Until %repeater% Equals "1"
      If Window "Program Manager" is focused
        Delay: 1000 milliseconds, without ability to halt
      Else
      // Clear previous mouse positions
        Variable Set Integer %left1% to 0
        Variable Set Integer %left2% to 0
        Variable Set Integer %right1% to 0
        Variable Set Integer %spanright1% to 0
        Variable Set Integer %spanleft1% to 0
        // Check for first right/left movement
        Get Mouse Position into (%left1%, ypos) Relative to Screen
        Delay: 150 milliseconds, without ability to halt
        Get Mouse Position into (%right1%, ypos) Relative to Screen
        Variable Modify Integer: %spanright1% = %right1% - %left1%
        If Variable %spanright1% Is Greater Than "%movement%" // Did mouse move right?
          Delay: 400 milliseconds, without ability to halt
          Get Mouse Position into (%left2%, ypos) Relative to Screen
          Variable Modify Integer: %spanleft1% = %right1% - %left2%
          If Variable %spanleft1% Is Greater Than "%movement%" // Did mouse move left?
             Macro Run: 1_Close_Application_or_Browser_Window
          End If
        End If
        //  
      End If
    End Repeat
    //  
    Macro Return
    //  

     


    <COMMENT Value="Track mouse, cancel application for rapid movement left to right and back"/>
    <COMMENT Value="This macro is intended to run virtually all the time, in a continuous loop"/>
    <COMMENT Value=" "/>
    <VARIABLE SET INTEGER Option="\x00" Destination="%movement%" Value="150" _COMMENT="Set minimum distance that qualifies as a mouse movement\r\n"/>
    <COMMENT Value=" "/>
    <VARIABLE SET STRING Option="\x00" Destination="%repeater%" Value="0" NoEmbeddedVars="FALSE"/>
    <REPEAT UNTIL Variable="%repeater%" Condition="\x00" Value="1"/>
    <IF WINDOW Option="\x00" Title="Program Manager" Partial="TRUE" Wildcards="FALSE"/>
    <DELAY Flags="\x13" Time="1000"/>
    <ELSE/>
    <COMMENT Value="Clear previous mouse positions "/>
    <VARIABLE SET INTEGER Option="\x00" Destination="%left1%" Value="0"/>
    <VARIABLE SET INTEGER Option="\x00" Destination="%left2%" Value="0"/>
    <VARIABLE SET INTEGER Option="\x00" Destination="%right1%" Value="0"/>
    <VARIABLE SET INTEGER Option="\x00" Destination="%spanright1%" Value="0"/>
    <VARIABLE SET INTEGER Option="\x00" Destination="%spanleft1%" Value="0"/>
    <COMMENT Value="Check for first right/left movement "/>
    <GET MOUSE POSITION Option="\x00" X="%left1%" Y="ypos"/>
    <DELAY Flags="\x13" Time="150"/>
    <GET MOUSE POSITION Option="\x00" X="%right1%" Y="ypos"/>
    <VARIABLE MODIFY INTEGER Option="\x01" Destination="%spanright1%" Value1="%right1%" Value2="%left1%"/>
    <IF VARIABLE Variable="%spanright1%" Condition="\x03" Value="%movement%" IgnoreCase="FALSE" _COMMENT="Did mouse move right?"/>
    <DELAY Flags="\x13" Time="400"/>
    <GET MOUSE POSITION Option="\x00" X="%left2%" Y="ypos"/>
    <VARIABLE MODIFY INTEGER Option="\x01" Destination="%spanleft1%" Value1="%right1%" Value2="%left2%"/>
    <IF VARIABLE Variable="%spanleft1%" Condition="\x03" Value="%movement%" IgnoreCase="FALSE" _COMMENT="Did mouse move left?"/>
    <MACRO RUN Use_ID="FALSE" Name="1_Close_Application_or_Browser_Window" ID="-1" Wait="TRUE"/>
    <END IF/>
    <END IF/>
    <COMMENT Value=" "/>
    <END IF/>
    <END REPEAT/>
    <COMMENT Value=" "/>
    <MACRO RETURN/>
    <COMMENT Value=" "/>

     

     

     

  3. For a black/white split area, where left and right margins are known and black is on the left, this script will find the dividing line within two or three pixels.  It only retrieves 13 pixels.  13 may be one or two more than necessary -- I haven't done the exact math.  For an area bigger than 1900 you might have to increase the Repeat count to 14 or 15.  To get the exact dividing line a little more code would have to be added, to step through the last two or three pixels one at a time.

    I moved the mouse, and inserted a half-second delay during each Repeat, so I could watch it run.  Get rid of the delay and it runs very quickly.  

     

    // xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    Variable Set Integer %left% to 1
    Variable Set Integer %right% to 1900
    //  
    Repeat Start (Repeat 13 times)
      Variable Modify Integer: %midpoint% = %left% + %right% // midpoint of area to search is left margin plus right margin divided by 2
      Variable Modify Integer: %midpoint% = %midpoint% / 2
      //  
      Mouse Move: %midpoint%, 400 Relative to Screen // move mouse to midpoint, get pixel color
      Get Pixel Color from Beneath the Mouse into %color%
      //  
      If Variable %color% Equals "0"
        Variable Modify Integer set %left% to the contents of %midpoint%
      Else
        Variable Modify Integer set %right% to the contents of %midpoint%
      End If
      Delay: 500 milliseconds
    End Repeat
    //  
    Text Box Display: Diagnostics
    //  
    Macro Return

     


    <COMMENT Value="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"/>
    <VARIABLE SET INTEGER Option="\x00" Destination="%left%" Value="1"/>
    <VARIABLE SET INTEGER Option="\x00" Destination="%right%" Value="1900"/>
    <COMMENT Value=" "/>
    <REPEAT START Start="1" Step="1" Count="13" Save="FALSE"/>
    <VARIABLE MODIFY INTEGER Option="\x00" Destination="%midpoint%" Value1="%left%" Value2="%right%" _COMMENT="midpoint of area to search is left margin plus right margin divided by 2"/>
    <VARIABLE MODIFY INTEGER Option="\x03" Destination="%midpoint%" Value1="%midpoint%" Value2="2"/>
    <COMMENT Value=" "/>
    <MOUSE MOVE Option="\x01" X="%midpoint%" Y="400" _PROMPT="0x000A" _COMMENT="move mouse to midpoint, get pixel color"/>
    <GET PIXEL COLOR Option="\x00" Rel_To_Screen="TRUE" Destination="%color%"/>
    <COMMENT Value=" "/>
    <IF VARIABLE Variable="%color%" Condition="\x00" Value="0" IgnoreCase="FALSE"/>
    <VARIABLE MODIFY INTEGER Option="\x06" Destination="%left%" Variable="%midpoint%"/>
    <ELSE/>
    <VARIABLE MODIFY INTEGER Option="\x06" Destination="%right%" Variable="%midpoint%"/>
    <END IF/>
    <DELAY Flags="\x12" Time="500"/>
    <END REPEAT/>
    <COMMENT Value=" "/>
    <TEXT BOX DISPLAY Title="Diagnostics" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}{\\f1\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs20 Black/White margin is at %midpoint%\\f1 \r\n\\par }\r\n" Left="Center" Top="Center" Width="278" Height="200" Monitor="0" OnTop="FALSE" Keep_Focus="TRUE" Mode="\x00" Delay="0"/>
    <COMMENT Value=" "/>
    <MACRO RETURN/>

     

  4. On 12/31/2020 at 11:57 AM, acantor said:

    We are searching for a red, vertical line that is one pixel wide.

     

    1. Move the mouse pointer to the left edge of the window that contains the red line.

    2. Search right, 64 pixels at a time until the pixel colour is [not] some colour, or is red.

    3. Search right, 32 pixels at a time until the pixel colour is [not] some colour, or is red.

    etc.

    Binary search, of sorts.  This would work extremely well to find the dividing line between two colors.  Even a full-screen search 1920 pixels wide would only require retrieving about a dozen pixels.  But for more than two colors it gets sketchy. 

  5. If the macro is working, you must not have corrupted it enough to worry about.  

     

    Here's a suggestion, somewhat related to your question:

    If you have to change the text with any frequency, you could maintain it in a Notepad document, where it is easy to edit.  Your macro could open the Notepad text file, copy all to the clipboard, put clipboard contents into a variable, and type the variable.  You would "never" have to touch the macro again. 

  6. P.S.  Getting pixel relative to window, I wanted to use the Windows clock as a timer.  So I started the macro, then within a second or so I clicked down in the lower right of the screen to open up the calendar and clock display.  As soon as I clicked and took focus away from the original window, the macro would complete almost instantly.  I displayed the Repeat counter in a text box at the end of the repeats, so I know it was completing "normally".  I would guess that when the window loses focus, ME bypasses whatever system interaction that otherwise would take all the time.  If getting pixel relative to screen, then taking focus away didn't make a difference in timing. 

  7. I use that technique a lot.  It looks like your code should work.  If the macro isn't ending, are you sure the pixel is really changing to the color you want?  Since you are checking for location relative to the screen (not the window), a slightly different window position or a different screen resolution (different computer?) could cause this.  Also, sometimes certain shades on my screen will be made up of alternating pixel colors -- for example, getting a gray color by intermixing black and white pixels -- so if you are only one pixel off in location the test won't be reliable. 

     

    For debugging purposes, put a Text Box Display inside the Repeat loop, right after the Get Pixel, displaying the N[2] value. 

     

    Incidentally, I like to Repeat a set number of times -- then Repeat Exit when the desired color is detected -- rather than Repeat indefinitely like you are doing.  For example, Repeat 100 Times, with a delay of 100ms on each pass through the loop, allows a nominal 10 seconds for the color to appear, then ends the loop no matter what.  You can then check the color one more time, and display a message if it was not found.  Here's an example: when the Repeat loop ends, either successfully or because the attempts are exhausted, the last color found is checked again to determine whether the search was successful or not.

     

    // Wait for "See Times" button to change color with mouse hovering over it
    Mouse Move: 957, 270 Relative to Screen
    Repeat Start (Repeat 100 times)
      Get Pixel Color from Beneath the Mouse into %N[1]%
      If Variable %N[1]% Equals "11355650"
        Repeat Exit
      Else
        Delay: 100 milliseconds
      End If
    End Repeat
    If Variable %N[1]% Equals "11355650"
      Mouse Left Click
      Macro Return
    Else
      Text Box Display: Error
      Macro Return
    End If

     

     

  8. 11 hours ago, acantor said:

    If it's any consolation, in Office applications, Microsoft changes the key sequences for performing everyday tasks, as well. That means that MEP scripts must be revised.

    Some consolation!  I suspect Microsoft rewards their employee-of-the-month by saying, "Here's a popular product, go ahead and have some fun by making whatever random design change strikes your fancy." 

     

    I just spent 30 minutes trying to turn off an "error" option in Excel.  I could turn it off for a particular spreadsheet but it would turn itself back on almost immediately.  Finally read an online hint to click File and Options, and that way I could turn it off universally and it would stay off.  The oddest thing is, this is a monthly spreadsheet and the "errors" just started showing up this month, after seven years of data.  Must have been from one of those Office updates that sneaked in without telling me now that I'm on Windows 10.  Things like this no longer surprise me, just reinforce my love/hate relationship with Microsoft.

  9. I use a variant of this technique for saving e-mails to existing folders, though not for creating new folders since I do that only rarely.  Some email sources have a consistent window title, others can be reliably identified by phrases in their content or simply by the "to" or "from" fields.  To dispose of an email that's on the screen, I start a macro that analyzes these items, sends it to the appropriate folder, or deletes it if it doesn't qualify for saving.  I admit the macro clicks on screen icons to do its work, so when GMail changes its layout the macro has to be adjusted.  But that doesn't happen often. 

  10. You could look into the instruction "Wait for Key Press" which has many wait options other than "key."  You might be able to do something with that.  You can start a macro (or multiple macros) that just sit on the Wait instruction, then when the key-press occurs the waiting macro can run some other macro.  Unfortunately the wait appears to deal only with three mouse keys, not four or five, but you could potentially set up a combination of mouse keys or letters.  It might be tricky and involve multiple macros.  Good luck!

  11. For what it's worth -- Here are some hints from another forum that I follow.  No warranty expressed or implied.
     

    Always remember: "Microsoft is arrogant and will *tell you* what you want" and "Google wants to know and control everything about you, all the time"

    To that end, here are some easy tips to speed up Win 10.

    1. Ctrl-Shift-Esc for task manager, go to Startup tab. Disable Onedrive.

    2. Hit windows key, search for 'background apps'  Turn them all off

    3. Open Chrome. Settings, Advanced.
         a. Preload pages- off
         b. Continue running background apps - off

    4. If using SSD, turn off SysMain service

    5. Install AVG free (if home computer). Disable AVG Secure brower, disable Web Shield, disable cleanup. (MS Defender will move out of the way, it is VERY SLOW)

    6. Add Malwarebytes free (if home computer). Like AVG, the paid versions are 'too heavy' and drag down system performance.

    Bang, 10-30% increase from just those few things. The difference should be noticeable upon reboot.

    Consider upgrading to SSD drive. They are pretty cheap these days.

    In task manager you can look at performance tab and see if it is amount of memory, Processor, or disk drive that is the anchor. Memory is easily upgraded, disk drive intermediate (maybe difficult on some laptops) with cloning or reinstall necessary.

     

  12. 46 minutes ago, acantor said:

    I don't think there was on-line ordering in that antediluvian age. I may have mailed a letter to Insight Software, with a completed order form, plus a cheque or my credit card number.

    Being south of the border, I had to send a check rather than a cheque. 

     

    But my other question: What is ME 5?  Is it just ME 4 under a different name?

     

    And still more questions: I tried to convert to from ME 3 to ME Pro back around 2009, for a pretty complex application running on 350 PCs, as I recall.  Nothing much worked during testing, so I stayed with ME 3.  I just recently converted my home PC from ME 3 to ME Pro, and I'm still seeing ME Pro crash about once a day.  So to finally get to my questions: Did you experience any significant pain going to ME 6, or was it neat and clean?  Was there an automated macro conversion involved, like there was in moving from ME 3 to ME Pro?

  13. 1 hour ago, acantor said:

    According to the revision history, there were eight (!) releases during the past month

    That's called the bleeding edge.

     

    1 hour ago, acantor said:

    In the Macro Express Explorer, click "Help" and then "About." The About screen has a message that tells you whether your version is up-to-date.

    Must be a version 6 thing.  Mine tells me it is 4.9.1.1, but no additional message.

     

    What is ME 5?  Just updates to ME 4 under a different name so they can start charging for it? 

     

    I got used to "free".  I don't remember, but I think I paid about $15 for ME, and used the pre-Pro versions for about twenty years.  That's 75 cents a year for a tool I said added 50% to my productivity.  I always felt guilty when I installed updates, and worried that Insight would go out of business for lack of revenue. 

  14. Now here's a cute idea.  I started a macro that runs indefinitely -- entire macro is below.

     

    So whenever I press the ESC key the macro types your suggested sequence to close the active application window.  Then the macro just waits until I'm ready to close another one.  Works great with Windows 7, but again ME does not see the ESC key in many Windows 10 operating system screens, so still no dice.  The other problem with this, even in Windows 7, is the limited number of keys that can be waited for.  I'd rather use a key that is "never" used any other time.    

     

    Repeat Until %A% Does not Equal %A%
      Wait for Key Press: ESC
      Text Type (Simulate Keystrokes): <ALTD><SPACE><ALTU>
      Delay: 100 milliseconds
      Text Type (Simulate Keystrokes): c
    End Repeat

     

  15. 2 hours ago, Samrae said:

    I failed to mention that my macro is activated with Ctrl+Alt+a. It works whether or not Settings is already loaded. in other words, a Ctrl+Alt+a hotkey works as an activation from within the Settings application.

    You have given me hope.  I have a Windows 10 system on order, and I'll have a lot more time to experiment once I get everything else converted to it. 

  16. 52 minutes ago, acantor said:

    Text Type (Simulate Keystrokes): <ALT><SPACE>
    Delay: 100 milliseconds
    Text Type (Simulate Keystrokes): c

     

    It's the key sequence I use dozens of times a day to close windows.

     

    Every bit as good as my method of finding the upper right corner and clicking on the "X".  Except my macro closes just one tab at a time (Ctrl-w) if Firefox is the active application. 

     

    But my problem is getting the macro to run at all, so that it can simulate the keystrokes you outlined.  As Cory explained, in the UWP applications in Windows 10, ME never even sees the hotkey to trigger the macro.  The beauty of the keypad-minus key is, many applications give you the option to save/no save your work when you exit, so I can just hit the minus key with my middle finger and roll my thumb down to the Enter key to confirm saving.  Very fast, and no looking for keys.  But I bet I can get used to a manual Alt-Space-c, if I have to. 

  17. 3 hours ago, Cory said:

    MEP doesn't work with them.

    "Doesn't work with them", in this case, seems to mean that while the application is running, MEP doesn't see key strokes and therefore can't start macros. 

     

    I have seen the same ME problem under Windows 7, with the Adobe PDF Reader.  Adobe says the reader runs in Protected Mode as a security feature.  With Adobe the Protected Mode can be turned off, and then ME is happy.   

×
×
  • Create New...