Jump to content
Macro Express Forums

rberq

Members
  • Posts

    1,200
  • Joined

  • Last visited

  • Days Won

    61

Everything posted by rberq

  1. 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=" "/>
  2. 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/>
  3. 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.
  4. 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.
  5. 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.
  6. Yes, your macro runs painfully slowly on my PC, also. About 12 to 15 seconds. Doesn't matter whether I get colors relative to screen or relative to window. Windows 10 Pro, ME Pro 4.9.1.1
  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. An integer variable may be set to the position of a substring within the text. So if you find it at position 1, then "replace". There's an option within "replace" to do it once only, or for all occurrences.
  9. 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.
  10. 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.
  11. I ran ME 3 for many months on Win 10. I don't remember whether it asked that on the very first startup, but it was OK otherwise. Are you saying it asks every time it starts?
  12. 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!
  13. So don't keep me in suspense! I'm apparently doing my activations incorrectly, also. Please tell! 😬
  14. 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.
  15. 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?
  16. That's called the bleeding edge. 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.
  17. Yes, please. I immediately looked for an update beyond 4.9.1.1, but found none. Updating version 6, maybe?
  18. 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
  19. 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.
  20. Little things like that save a lot of time and aggravation when you are coding.
  21. 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.
  22. Yes! It does! So now if I can figure out the name of that little window, I'll see if it can trigger a macro that types the "c". You say it's called the Windows System menu?
  23. For example, the Windows Setup screen and the various screens that can be accessed from there.
  24. "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.
  25. Since my hands are most often on the keyboard, I prefer using keys to using the mouse. One of my most-used macros closes the current application. If Firefox is active, it types Ctrl-w to close the active tab. Otherwise, it clicks in the upper right corner of the active application’s window. The macro is activated by the keypad minus key, and it’s generally quicker to press the key than to manually maneuver the mouse or to press that awkward Alt-F4 combination. Here’s the problem: In many Windows 10 system screens, the key is ignored so the macro doesn’t run. Other hotkey combinations are also ignored – like Ctrl-Alt-w that runs a macro to display all open windows. Is there a Windows 10 setting, or some trick, to overcome this issue?
×
×
  • Create New...