A few scripting questions :) for a Noob

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
diamondrail
Newbie
Posts: 17
Joined: Wed Jul 31, 2019 9:38 am

A few scripting questions :) for a Noob

Post by diamondrail » Wed Oct 02, 2019 8:30 am

1. Is there a good way to automate clicking a button on a webpage, when a) the button is not currently shown on the page - it is scrolled down a few pages? and b) if the mouse is hovering over the button causing the tiny little pop up box to pop up and "cover" up the button... (in the situation where you might be using a image recognition script)

2. Is there a command to open a new Internet Explorer Browser, instead of opening a new tab in an existing already open Internet Explorer Browser page?

3. Is there a way to condense a working script so I can just reference that script as one line of code. instead of having to copy and paste the entire code into that spot.

4. If I want a script to run at 9am (900), then 1015am (1015), and ten other random times throughout the 24 hour day. Is it better to just use a OR STATEMENT or is there a more elegant way to set this up?

5. Is there a script to close the internet explorer window that is currently open and "on top". I only want to close one window. The current active and open internet explorer window. The name of this window may change as well.

6. Lastly, is there a way to edit the Subject of my post on this forum, so I can make note if the post has been solved?

User avatar
Dorian (MJT support)
Automation Wizard
Posts: 478
Joined: Sun Nov 03, 2002 3:19 am
Contact:

Re: A few scripting questions :) for a Noob

Post by Dorian (MJT support) » Wed Oct 02, 2019 2:12 pm

diamondrail wrote:
Wed Oct 02, 2019 8:30 am
1. Is there a good way to automate clicking a button on a webpage, when a) the button is not currently shown on the page - it is scrolled down a few pages? and b) if the mouse is hovering over the button causing the tiny little pop up box to pop up and "cover" up the button... (in the situation where you might be using a image recognition script)
A button doesn't necessarily have to be visible to be clicked if you're using the native IE functions. If you were to use the Find IE Element Wizard to generate code to click on a button, it clicks it anyway.

The following code opens IE, navigates to Microsoft, and then clicks terms and conditions at the bottom, which is way out of view.

Code: Select all

//Set the variables
Let>TheURL=https://microsoft.com/

//Create an IE instance
IECreate>IE[0]
WaitWindowOpen>Internet Explorer*

//Navigate
IENavigate>IE[0],TheURL,IEnavres
IEWait>%TheURL%

//Click "terms of use" at the bottom of the page
IETagEventByAttrib>{"https://www.microsoft.com/en-gb/"},A,innertext=Terms of use,click,

However, it's worth pointing out that I've noticed a lot of users log in to a site, and then use menus or button clicks to navigate to a particular part of a website, when that URL is static and once logged in (if they even need to) they could simply have just navigated there :

Code: Select all

//Set the variables
Let>TheURL=https://www.microsoft.com/en-us/legal/intellectualproperty/copyright/default.aspx

//Create an IE instance
IECreate>IE[0]
WaitWindowOpen>Internet Explorer*

//Navigate
IENavigate>IE[0],TheURL,IEnavres
IEWait>%TheURL%

diamondrail wrote:
Wed Oct 02, 2019 8:30 am
2. Is there a command to open a new Internet Explorer Browser, instead of opening a new tab in an existing already open Internet Explorer Browser page?
IECreate should open the browser. If you're wishing to do this via clicking on a link in an existing IE session though it would be helpful to see the page in question. There is not a single command to do this.

diamondrail wrote:
Wed Oct 02, 2019 8:30 am
3. Is there a way to condense a working script so I can just reference that script as one line of code. instead of having to copy and paste the entire code into that spot.
Yes. if I am understanding correctly :

Include
Macro

I would also suggest looking at Gosub. You can simply hide all your subroutines at the bottom and call them multiple times.

diamondrail wrote:
Wed Oct 02, 2019 8:30 am
4. If I want a script to run at 9am (900), then 1015am (1015), and ten other random times throughout the 24 hour day. Is it better to just use a OR STATEMENT or is there a more elegant way to set this up?
When you say random times, do you actually mean completely random? Can you explain a little more? This may need an answer all to itself.

diamondrail wrote:
Wed Oct 02, 2019 8:30 am
5. Is there a script to close the internet explorer window that is currently open and "on top". I only want to close one window. The current active and open internet explorer window. The name of this window may change as well.
You could use GetActiveWindow and then close it. Maybe check to see if the title contains the string "Internet Explorer". You could also use GetWindowList as that returns the list on order of most recent first. so you could use that to close the most recent IE window.

diamondrail wrote:
Wed Oct 02, 2019 8:30 am
6. Lastly, is there a way to edit the Subject of my post on this forum, so I can make note if the post has been solved?
If you're able to edit your post (the little pencil icon) then you should be able to edit the subject - I think!
Always accepting custom script commissions. Message me or go here

diamondrail
Newbie
Posts: 17
Joined: Wed Jul 31, 2019 9:38 am

Re: A few scripting questions :) for a Noob

Post by diamondrail » Wed Oct 02, 2019 7:57 pm

4. If I want a script to run at 9am (900), then 1015am (1015), and ten other random times throughout the 24 hour day. Is it better to just use a OR STATEMENT or is there a more elegant way to set this up?


Should be better explained as:

4. If I want a script to run at 9am (900), then 1015am (1015), and then at ten other specific times throughout the 24 hour day. Is it better to just use a OR STATEMENT or is there a more elegant way to set this up?

Post Reply