|
Post by Rambo-X on Nov 6, 2020 15:36:44 GMT
Good Day Everyone !
I hope all of you are safe and sound with your families from Covid19.
Even before I ask my Question I'd like to thank the Creators of this software as this is my first question in here.
I also have asked support from Mr. Excel forum hoping some form of support may come from the excel community of Macro.
But going through the forum questions I realized the answer must be simple but my search words are all wrong or I do not understand the solutions presented here.
So I'd like to apologize if I sound really Newbie.
My problem is simple to understand. I have recorded heaps and heaps of Macros. And I recently wanted to share some of them with my team mates to make our day to day work easier. But they don't run the same in different screen sizes. Mine is a 15inch laptop. One other friend has 24inch Monitor and another has a 13inch laptop. How do I change 1000+ lines long Macro's X and Y coordinates which has minor changes every few lines because "replace" option doesn't seem like the Solution.
Many Thanks.
|
|
|
Post by Rambo-X on Nov 6, 2020 16:34:51 GMT
Trying to do some math I realized, No matter the Screen Sizes change the Ratios are consistent. For an Example, If my Laptop is, X0 as Old - 1376 Y0 as Old - 768 X1 as New - 1920 Y1 as New - 1080 if my Laptop Mouse Pointer is at, 836 | 50, New Coordinates would be, 1920/1376 x 836 - 1166 ( X1 ) Percentage = 139% 1080/768 x 50 - 70 ( Y1 ) = 140% 139%=%INTEGER1% 140%=%INTEGER2% Having a looked at User ID: Johnc's recent question can we not to something like below? 220 | 836 x %INTEGER1% | 50 x %INTEGER2% | 500 | Left Click Down Just suggesting
|
|
|
Post by Steve on Nov 10, 2020 6:54:42 GMT
Hi Rambo-XGreat question. Thank you for posting this one to the forum. Unfortunately the solution is not a simple one and knowing what MMM is capable of i'd say it would be better to do it outside of MMM. I've been delayed in getting some of the updates out for MMM but a focus of mine is improving some of these math functions. For now i'd recommend running a script over your .mmmacro saved file that converts your mouse X and Y coords to the environment you need. Id prob say something in python. Hope this helps.
|
|
|
Post by Rambo-X on Nov 23, 2020 0:43:22 GMT
Hello Steve, Thank you very much for your reply. But unfortunately I have no any knowledge in Python or it's functions. Or even how to apply it.
|
|
|
Post by Rambo-X on Nov 23, 2020 0:56:02 GMT
Furthermore to your suggestion,
Is it possible to run mmmacro codes (if I have given macro's within macro's without any flow control) as a python script if screen sizes are same keep changing the mmmacro file name and get a job done?
Because most my work is web based work and emails. Wish I can code in mmmacro and run them via Python as far as I can do some other work in background.
|
|
|
Post by Steve on Nov 23, 2020 9:19:08 GMT
Hi Rambo-XThis macro should do the trick. 1 | RUN ACTION | RUN VIA CMD /C | wmic path Win32_VideoController get CurrentHorizontalResolution,CurrentVerticalResolution > w:\macro\output\res.txt 2 | RUN ACTION | INPUT FROM FILE | STRING::NO_REFRESH::W:\Macro\OUTPUT\res.txt 3 | IF | STRING VARIABLE | %STRING% | CONTAINS | 1 9 2 0 | ADD MACRO FROM FILE | W:\Macro\desktop_res.mmmacro | ELSE | 3 | RUN ACTION | ADD MACRO FROM FILE | W:\Macro\laptop_res.mmmacro Line 1 - We get the current resolution from the command line and write it out to a file called w:\macro\output\res.txt Line 2 - We load that file (res.txt) into the variable %STRING% Line 3 - If %STRING% contains 1 9 2 0 (the spaces are needed. the output at res.txt has spaces for some reason) then we add macro our desktop_res.mmmacro file in and run it. If the file does not contain 1 9 2 0 then the resolution must not be 1920 by 1080 so ELSE load in the laptop_res.mmmacro file. I think this is probably your best bet. Have two macro files one with your 1920 res and one with your laptop res. Hope this helps.
|
|
|
Post by Rambo-X on Nov 23, 2020 9:58:39 GMT
Steve Hi,
I am not an expert so bit lost in here... How should I apply this to my existing mmmacro file? Because I have Macros running within macros with no flow control? If you could give some more clarity on how should I apply this, I'd be extremely grateful.
Thank you again for this great App.
|
|
|
Post by Rambo-X on Nov 23, 2020 10:00:15 GMT
Also If I am using &String% variables in my Macro, could that mess this resolution coding?
|
|
|
Post by Steve on Nov 23, 2020 18:52:14 GMT
Ok Step 1: Create a .mmmacro saved macro called checkres.mmmacro and paste in the three macro lines I posted Step 2: Create a .mmmacro saved macro called desktop_res.mmmacro. This macro has the X and Y coordinates needed for your Desktop setup. Step 3: Create a .mmmacro saved macro called laptop_res.mmmacro. This macro has the X and Y coordinates needed for your laptop setup. Step 4: Run checkres.mmmacro. This will determine what screen res you currently have and run desktop_res or laptop_res depending on your current res. Steve Hi, I am not an expert so bit lost in here... How should I apply this to my existing mmmacro file? Because I have Macros running within macros with no flow control? If you could give some more clarity on how should I apply this, I'd be extremely grateful. Thank you again for this great App. Flow control will be fine because the add macro from file action appends the file to the current macro. Check out www.turnssoft.com/conditions.html#addmacrofromfile, and create yourself a test to check it out. Also If I am using &String% variables in my Macro, could that mess this resolution coding? Yes. If your using %STRING% somewhere else then either overwrite the variable or use a different variable. Perhaps %STRING99%.
|
|
|
Post by Rambo-X on Nov 24, 2020 12:32:52 GMT
Hi Steve, Could you please be kind enough to advise me a bit more further? I am lost on Step 2 and 3, Step 2: Create a .mmmacro saved macro called desktop_res.mmmacro. This macro has the X and Y coordinates needed for your Desktop setup. I don't understand what exactly you mean or suggested me here. Do you mean to say I have to change all my current Laptop Resolution X|Y Numbers to Desktop X|Y Resolution numbers? That was my issue in the first place... Not to change my existing X|Y Coordinates because it's not just a code or two I did in my laptop. There are hundreds of coding we are talking here over 500-1000 lines each. Step 3: Create a .mmmacro saved macro called laptop_res.mmmacro. This macro has the X and Y coordinates needed for your laptop setup. This is just a renaming which I can do and make it run from file. So there are no issues in here. So am I missing something here?
|
|
|
Post by Rambo-X on Nov 24, 2020 12:50:24 GMT
Further more to add, I was worried about the Macro's within Macros given as RUN MACRO INLINE because they too have the Laptop Resolutions given. From How I understood or misunderstood your 3 line codings was it determines which ones to run from an existing set of codes yeah? I sincerely hope Not and what you have suggested here is misinterpreted by me. And my biggest challenge is how to change those X|Y Coordinates in the first place to fit the Desktop resolution. I stay fingers crossed hoping your answer to this would be the solution I have been waiting. Thank you.
|
|
|
Post by Steve on Nov 24, 2020 22:15:33 GMT
I am lost on Step 2 and 3, Step 2: Create a .mmmacro saved macro called desktop_res.mmmacro. This macro has the X and Y coordinates needed for your Desktop setup. I don't understand what exactly you mean or suggested me here. Do you mean to say I have to change all my current Laptop Resolution X|Y Numbers to Desktop X|Y Resolution numbers? That was my issue in the first place... Not to change my existing X|Y Coordinates because it's not just a code or two I did in my laptop. There are hundreds of coding we are talking here over 500-1000 lines each. Yes I as suggesting this. I am suggesting you have three macro files in total. One that drives the logic that determines your current resolution and then one for each of the resolution types. I think you may have misunderstood my original comments here: Hi Rambo-X Great question. Thank you for posting this one to the forum. Unfortunately the solution is not a simple one and knowing what MMM is capable of i'd say it would be better to do it outside of MMM. I've been delayed in getting some of the updates out for MMM but a focus of mine is improving some of these math functions. For now i'd recommend running a script over your .mmmacro saved file that converts your mouse X and Y coords to the environment you need. Id prob say something in python. Hope this helps. To dynamically change the X and Y coords of a saved .mmmacro file is better suited for a fully fledged scripting language such as Python or Powershell. MMM is not a scripting language, it is a macro tool with some scripting functionality. In order to do what you are after dynamically (and by dynamically I mean programmatically) you need proper string manipulation outside the current capability of MMM. You've mentioned in a previous post your not familiar with scripting languages like Python. So I can see your predicament. You have three options the way I see it. The first being to manually create that other macro to match your different resolution and then implement the solution above. The second being to learn the basics of scripting and give it a go in Python or Powershell...maybe even a clever batch script. The third is to visit some Python forums and ask for some scripting help. Further more to add, I was worried about the Macro's within Macros given as RUN MACRO INLINE because they too have the Laptop Resolutions given. From How I understood or misunderstood your 3 line codings was it determines which ones to run from an existing set of codes yeah? I sincerely hope Not and what you have suggested here is misinterpreted by me. And my biggest challenge is how to change those X|Y Coordinates in the first place to fit the Desktop resolution. I stay fingers crossed hoping your answer to this would be the solution I have been waiting. Thank you. This command run from the windows command shell outputs your current screen resolution: wmic path Win32_VideoController get CurrentHorizontalResolution,CurrentVerticalResolutionThe output of this command fed into %STRING% allows us to run some logic to determine which macro to load. If your current screen res is your desktop res then we load your macro with the desktop res. If you current screen res is your laptop res then we load your macro with the laptop res. Hope this helps.
|
|
|
Post by Rambo-X on Nov 24, 2020 23:26:58 GMT
Thanks for your detailed explanation. I will give it a try at some forums from Python. Thank you again for your support. Means a lot.
|
|
|
Post by zeak on Dec 7, 2020 6:48:09 GMT
So I had a random thought about checking screen size and here is what I came up with.
1 | 9999 | 9999 | 100 | Mouse Movement 2 | RUN ACTION | DEFINE INTEGER VARIABLE | %INTEGER%::%MOUSE_X% 3 | RUN ACTION | DEFINE INTEGER VARIABLE | %INTEGER1%::%MOUSE_Y% 4 | RUN ACTION | MESSAGE PROMPT | Screen Width - %INTEGER%, Screen Height - %INTEGER1%::Screen Size::0 Then using the Integer's you could use calculations to determined where you want to click.
|
|
|
Post by zeak on Dec 7, 2020 6:54:39 GMT
I just refined it a bit further.
1 | 9999 | 9999 | 100 | Mouse Movement 2 | RUN ACTION | DEFINE INTEGER VARIABLE | %INTEGER%::%MOUSE_X% 3 | RUN ACTION | DEFINE INTEGER VARIABLE | %INTEGER1%::%MOUSE_Y% 4 | RUN ACTION | DEFINE INTEGER VARIABLE | %INTEGER%::+1 5 | RUN ACTION | DEFINE INTEGER VARIABLE | %INTEGER1%::+1 6 | IF | INTEGER VARIABLE | %INTEGER% | GREATER THAN | 2500 | DEFINE INTEGER VARIABLE | %INTEGER%::/2 7 | RUN ACTION | MESSAGE PROMPT | Screen Width - %INTEGER%, Screen Height - %INTEGER1%::Screen Size::0 I noticed that is was 1 pixel off the proper size and this will look at the X and if over 2500 it will halve it to say the size of one screen.
|
|
|
Post by Rambo-X on Dec 7, 2020 19:05:52 GMT
After All the "Triple M" might managed to one day crack this if we can run a code for a macro to read line by line and then apply the calculated X and Y's to each of those lines to fit the resolution.
|
|