PDA

View Full Version : Browser Scroll



matthew98
08-10-2018, 02:17 PM
I'm using simba to automate a simple task in my browser.

Currently i'm using the code below to scroll using the right hand side bar on my chrome browser.



procedure scroll_4();
begin
mouse(944, 1005, 1);
HoldMouse(944, 1005, mouse_Left);
wait(800);
ReleaseMouse(944, 1005, mouse_Left);
wait(2000);
end


It uses a wait time and sometimes i find it a little unaccurate. Is there any better way to scroll down on a browser?

Perhaps scroll by the amount of pixels? Any help would be great, thank you.

Edited:

Just a thought, i could drag the bar down a certain amount of pixels. I think that may be more accurate.

acow
08-10-2018, 02:33 PM
It uses a wait time and sometimes i find it a little accentuate.
I'm not sure what exactly accentuate is supposed to mean in this context, but I would recommend considering using something like waitfunc (https://github.com/SRL/SRL-6/blob/d5817b11a391940d12180740a914a4cf5d72b204/lib/utilities/time.simba#L267) over waits in most of your script, regardless of it helping solve this specific issue. That way you're waiting until something happens (or doesn't happen), rather than simply waiting a predetermined amount of time.



Is there any better way to scroll down on a browser?

idk about better for you, but yes there are alternative ways a person could use to scroll down. You may wish to research the alternatives and test them out.



Perhaps scroll by the amount of pixels?

Would likely need to execute javascript code for that level of control, e.g. window.scrollBy() (https://developer.mozilla.org/en-US/docs/Web/API/Window/scrollBy)

P1nky
08-10-2018, 02:35 PM
Can you post a screenshot where you would like the scroll bar to stop/?

KeepBotting
08-10-2018, 02:36 PM
Could you use the arrow keys or PgUp/PgDown? Might be more precise than manipulating a scroll bar, since they differ from browser to browser and change as the length of the page changes.

Ctrl+F will also snap you to whatever is found as you search. Perhaps you could have your script use Ctrl+F?

matthew98
08-10-2018, 02:58 PM
Would likely need to execute javascript code for that level of control

How would i use javascript in pascal?

matthew98
08-10-2018, 03:01 PM
Could you use the arrow keys or PgUp/PgDown? Might be more precise than manipulating a scroll bar, since they differ from browser to browser and change as the length of the page changes.

Ctrl+F will also snap you to whatever is found as you search. Perhaps you could have your script use Ctrl+F?

That's genius. I will give the page down a try. That looks like it would work much better.

Do you know what the key number would be for page down and up? Struggling to find it.

Thank you.

matthew98
08-10-2018, 03:04 PM
Found it :) 34

acow
08-10-2018, 03:49 PM
How would i use javascript in pascal?
btw just to be clear, I wasn't trying to recommend you scroll by X pixels w/ javascript. Just answering your question with a yes it's possible but you'd likely need to execute javascript for that specific functionality.

Anyways, to answer your question here, the exact same ways as a human could. However ways a human could manually execute javascript code when on somebody else's website, you could easily do the same via simba. There's multiple ways to do that, a quick google search should give a couple of the options for that. Not that I'm recomending you execute javascript for this project that I know almost nothing about.

P1nky
08-10-2018, 04:00 PM
Try using this:

Begin
KeyDown(VK_Down);
wait(600);
KeyUp(VK_Down);
End;

Clarity
08-10-2018, 04:47 PM
Why not just scroll down until a certain condition is met, verified via color searches (I.e. getColor() or similarColors() or findDTM/Bitmap)? Presumably you are scrolling down until you see some page element in the window?

Maybe if you elaborate on the task you are trying to do we can provide more specific answers.

the bank
08-10-2018, 06:54 PM
Umm... I'll just leave this here.

http://docs.villavu.com/simba/scriptref/mouse.html

ActivateClient();
ScrollMouse(0, 0, numClicks); //numClicks = 'steps'

P1nky
08-10-2018, 07:13 PM
Umm... I'll just leave this here.

http://docs.villavu.com/simba/scriptref/mouse.html

ActivateClient();
ScrollMouse(0, 0, numClicks); //numClicks = 'steps'


Ding ding ding! We got a winner :)

matthew98
08-10-2018, 08:47 PM
Umm... I'll just leave this here.

ActivateClient();
ScrollMouse(0, 0, numClicks); //numClicks = 'steps'


Thank you!!