Scroll to Precise Window Location

General Macro Scheduler discussion

Moderators: Dorian (MJT support), JRL

Post Reply
User avatar
JRL
Automation Wizard
Posts: 3361
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Scroll to Precise Window Location

Post by JRL » Fri Oct 09, 2020 4:33 pm

I have a desire to use Macro Scheduler on a Remote Desktop session where I'm not allowed to install Macro Scheduler. The solution for me is to un-maximize the RDP session and manipulate it as you would any other window using mouse clicks and keyboard functions. I also want to reduce the size of the window and only work in specific areas without actually rearranging things in the RDP session. This can be accomplished by making the un-maximized RDP session window whatever size you want and then scrolling to the location(s) you want to work with. This is easily accomplished manually. I want to do it via Macro Scheduler. I searched but didn't find a workable method for precisely manipulating the scroll bars other than by mouse moves and clicks.

Below is an example of mouse click manipulation of the scrollbars in Notepad. The Notepad window settings are important to make this work properly, so if you try this make sure your Notepad is configured like mine. I know there are other things I could do, for example, a search for the "X" to produce a similar result in Notepad but I'm not really trying to manipulate Notepad, just using it to demonstrate.

The crux of this method is that when you right click on a scrollbar in many applications you get a menu where one of the menu options is "Scroll Here". So using MouseMoveRel> one can select a position on the scrollbar and scroll fairly precisely. If it works properly for you, it should scroll to the location of the only alpha character in the text file and center it in the window.

Does anyone know a better way? Precise scrolling is important.

Code: Select all

//Notepad font is set to Consolas, Regular, 11
//Notepad Status bar is on

//Delete File before creating it JIC
DeleteFile>%temp_dir%JRLTextFile.txt

//Create a file with an X in the middle
Let>vDoc=
Let>kk=0
Repeat>kk
  Add>kk,1
  Let>vLine=%TAB%%TAB%%TAB%%TAB%%TAB%%TAB%%TAB%%TAB%%TAB%%TAB%%TAB%%TAB%%TAB%%TAB%%TAB%%TAB%%TAB%%TAB%%TAB%%TAB%%TAB%%TAB%%TAB%%TAB%%TAB%%TAB%%TAB%%TAB%%TAB%%TAB%%TAB%%TAB%%TAB%%TAB%%TAB%%TAB%%TAB%%TAB%%crlf%
  If>kk=658
    Let>vLine=%TAB%%TAB%%TAB%%TAB%%TAB%%TAB%%TAB%%TAB%%TAB%%TAB%%TAB%%TAB%%TAB%%TAB%%TAB%X%TAB%%TAB%%TAB%%TAB%%TAB%%TAB%%TAB%%TAB%%TAB%%TAB%%TAB%%TAB%%TAB%%TAB%%TAB%%TAB%%TAB%%TAB%%TAB%%TAB%%TAB%%TAB%%TAB%%crlf%
  EndIF
  Let>vDoc=%vDoc%%vline%
Until>kk=6000
WriteLn>%temp_dir%JRLTextFile.txt,wres,vDoc
////////////////////////////////////////

//Open File in Notepad
RunProgram>notepad.exe %temp_dir%JRLTextFile.txt
WaitWindowOpen>JRLTextFile*
Wait>1
//////////////////////

//Position and size window as needed
GetWindowHandle>JRLTextFile*,hWndParent
Let>Win_Usehandle=1
MoveWindow>hWndParent,100,50
ResizeWindow>hWndParent,500,400
SetFocus>hWndParent
Let>Win_Usehandle=0
////////////////////////////////////

//Everything to this point is simply setting up
//a window with which to work.

//Mouse moves and clicks to manipulate the scroll bars
//Wait> functions are in place if you need them
MouseMoveRel>485,103
rClick
Wait>0
Send>s
Wait>0
Press Enter

MouseMoveRel>197,360
rClick
Wait>0
Send>s
Wait>0
Press Enter

MouseMoveRel>485,343
Let>LC=0
Repeat>LC
  Add>LC,1
  lClick
Until>LC=4
///////////////////////////////////////////////////////
Using Windows 10 and Macro Scheduler v15.0.12

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts