Auto click link every 30 mins and repeat

jimpatel1993
2StarLounger
Posts: 153
Joined: 31 Jan 2021, 09:12

Auto click link every 30 mins and repeat

Post by jimpatel1993 »

Hi

Thanks for looking at my post. I have excel with table which is having multiple links to websites in Microsoft edge. I am looking for some support for auto click each link one by one and close it every 30 mins please and repeat it please.
Any idea please
You do not have the required permissions to view the files attached to this post.

User avatar
SpeakEasy
4StarLounger
Posts: 535
Joined: 27 Jun 2021, 10:46

Re: Auto click link every 30 mins and repeat

Post by SpeakEasy »

>auto click each link one by one and close it

Just to be clear here - you want to open the link, and then close the page that this opens? Do you need to see the page?

jimpatel1993
2StarLounger
Posts: 153
Joined: 31 Jan 2021, 09:12

Re: Auto click link every 30 mins and repeat

Post by jimpatel1993 »

No not necessarily
Only thing is open and close so that the page wont go to sleep
Thanks a lot

jimpatel1993
2StarLounger
Posts: 153
Joined: 31 Jan 2021, 09:12

Re: Auto click link every 30 mins and repeat

Post by jimpatel1993 »

Any help is much appreciated

User avatar
SpeakEasy
4StarLounger
Posts: 535
Joined: 27 Jun 2021, 10:46

Re: Auto click link every 30 mins and repeat

Post by SpeakEasy »

Something like the following would be one approach.

Code: Select all

Option Explicit

Private MyTableName As String

Public Sub startit()
    MyTableName = "Table1" ' Sincxe we cannot pass parameters in OnTime event. Example uses Table1, but this is where your tablename would go
    Application.OnTime Now + TimeValue("00:00:05"), "ClickTableLinks"
End Sub

' requires reference to Microsoft Internet Controls
Public Sub ClickTableLinks() '(Optional Tablename As String = "Table1")
    Dim proxie As New InternetExplorer
    Dim mylink As Hyperlink
    If MyTableName = "" Then MyTableName = "Table1"
    For Each mylink In Range(MyTableName).Hyperlinks
        proxie.navigate mylink.Address
        ' You should really wait for the page to load fully here
        proxie.Quit
    Next
    ' Unremark the below to start another timer - but you'll want to add the capability to disable the timer if you do ...
    'Application.OnTime Now + TimeValue("00:00:05"), "ClickTableLinks"
End Sub

jimpatel1993
2StarLounger
Posts: 153
Joined: 31 Jan 2021, 09:12

Re: Auto click link every 30 mins and repeat

Post by jimpatel1993 »

Thanks a lot
Let me try this
Much appreciated

snb
4StarLounger
Posts: 547
Joined: 14 Nov 2012, 16:06

Re: Auto click link every 30 mins and repeat

Post by snb »

Or in the Thisworkbook macromodule:

Code: Select all

Dim t1, n

Private Sub Workbook_Open()
  n = 1
  M_snb
End Sub

Sub M_snb()
   t1 = DateAdd("n", 30, Now)
   Sheet1.Hyperlinks(n).Follow
   n = n Mod Sheet1.Hyperlinks.Count + 1
   Application.OnTime t1, "M_snb"
End Sub

Private Sub Workbook_BeforeClose(Cancel As Boolean)
   Application.OnTime t1, "M_snb", , False
End Sub

jimpatel1993
2StarLounger
Posts: 153
Joined: 31 Jan 2021, 09:12

Re: Auto click link every 30 mins and repeat

Post by jimpatel1993 »

Thanks for your input
I am getting an error in dim new internetexplorer line.
Am I doing anything wrong?
Thanks and much appreciated

User avatar
HansV
Administrator
Posts: 78234
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Auto click link every 30 mins and repeat

Post by HansV »

Did you set a reference (in Tools > References...) to Microsoft Internet Controls, as SpeakEasy mentioned in a comment in the code?
Best wishes,
Hans

User avatar
SpeakEasy
4StarLounger
Posts: 535
Joined: 27 Jun 2021, 10:46

Re: Auto click link every 30 mins and repeat

Post by SpeakEasy »

>Sheet1.Hyperlinks(n).Follow

There's a reason I didn't just do a simple Follow in my code, which is this:

>and close it

Follow doesn't provide you with anything to (easily) close ...
Last edited by SpeakEasy on 23 Nov 2022, 09:17, edited 1 time in total.

snb
4StarLounger
Posts: 547
Joined: 14 Nov 2012, 16:06

Re: Auto click link every 30 mins and repeat

Post by snb »

The default in hyperlinks(1).follow is 'newwindow=False'
Why 'closing' a windows that can show multiple hyperlinks ?

jimpatel1993
2StarLounger
Posts: 153
Joined: 31 Jan 2021, 09:12

Re: Auto click link every 30 mins and repeat

Post by jimpatel1993 »

Thanks a lot for your input.
If it is getting complicated then it wont be necessary to close the website please
Thanks a alot

User avatar
DocAElstein
4StarLounger
Posts: 545
Joined: 18 Jan 2022, 15:59
Location: Re-routing rivers, in Hof, Beautiful Bavaria

Re: Auto click link every 30 mins and repeat

Post by DocAElstein »

@SpeakEasy
Hi
About this,
….. ' Sincxe we cannot pass parameters in OnTime event.
.. I may have missed the point of what you were saying / meaning… so I guess just ignore me if that’s the case: I am not always sure what people are saying when they say parameters – some times they are what I think arguments are, sometimes not…
( I am also not quite following what it is that the OP, jimpatel1993 , wants exactly. )


If you were saying that we cannot pass arguments using On-Time , then I beg to differ.. The syntax is a bit tricky but seems to me that somehow you give it a string, which may then be stored somewhere and then pseudo pasted into a Application.Run type code line later. That is just an uneducated Layman guess, and it’s based on that I noticed you can add a lot of spaces, just as if you were typing / or pasting in manually and put too many spaces in - (It's based on this off beat way of thinking that you ( or I anyway), can Late Bind things that are apparently not possibly to Late Bind. ( or maybe the other way around, I forgot). The explanation is perhaps just as wrong, but it works, but that is perhaps something for another day)


This seems to work

Code: Select all

 Option Explicit
'Private MyTableName As String
Public Sub Startit()
'    MyTableName = "Table1" ' Sincxe we cannot pass parameters in OnTime event. Example uses Table1, but this is where your tablename would go
 Application.OnTime Now + TimeValue("00:00:03"), "'" & ThisWorkbook.Path & "\" & ThisWorkbook.Name & "'" & "!'Modul1.ClickTableLinks      00000465   ,     ""A first Word""          '"
End Sub

' requires reference to Microsoft Internet Controls
Public Sub ClickTableLinks(ByVal ANumber As Long, ByVal AWord As String) ' Tablename As String)  '  = "Table1")
'    Dim proxie As New InternetExplorer
'    Dim mylink As Hyperlink
'    If MyTableName = "" Then MyTableName = "Table1"
Debug.Print ANumber & "   " & AWord
'    For Each mylink In Range(MyTableName).Hyperlinks
'        proxie.navigate mylink.Address
'        ' You should really wait for the page to load fully here
'        proxie.Quit
'    Next
    '                                                                                                            Unremark the below to start another timer - but you'll want to add the capability to disable the timer if you do ...
    If ThisWorkbook.Worksheets.Item(1).Range("A1").Value2 = "Stop" Then Exit Sub '  write  Stop  in the first cell to stop the repeating
 Application.OnTime Now + TimeValue("00:00:03"), "'" & ThisWorkbook.Path & "\" & ThisWorkbook.Name & "'" & "!'Modul1.ClickTableLinks      0465   ,     ""A repeated Word""          '"
End Sub
'







' Simplified
Public Sub StartTit()
 Application.OnTime Now + TimeValue("00:00:03"), "'ClickerTityClick      465   ,     ""A First Word""          '"
End Sub
Public Sub ClickerTityClick(ANumber As Long, AWord As String)
Debug.Print ANumber & "   " & AWord
    If Range("A1").Value2 = "Stop" Then Exit Sub
 Application.OnTime Now + TimeValue("00:00:03"), "'ClickerTityClick      465   ,     ""A Repeated Word""          '"
End Sub
 
_.______________________________________________________________-

@ jimpatel1993
I am not sure exactly what you want the coding to do.
Could try to explain in more detail exactly what you want to happen?

I do not understand what this means? … so that the page wont go to sleep





Alan
You do not have the required permissions to view the files attached to this post.
I seriously don’t ever try to annoy. Maybe I am just the kid that missed being told about the King’s new magic suit, :(

User avatar
SpeakEasy
4StarLounger
Posts: 535
Joined: 27 Jun 2021, 10:46

Re: Auto click link every 30 mins and repeat

Post by SpeakEasy »

>I am not always sure what people are saying when they say parameters – some times they are what I think arguments are

Yes, formally they mean slightly different things - an argument is the actual value passed, a parameter is the definition of the expected argument. But in general conversation (well, IME) they are often considered to refer to the same thing.

> I beg to differ
yes, there is a quirk with the Excel VBA runtime engine's integration with Excel functionality that can be abused to allow this (try it in Word, for example), but it is a hack (and relying on hacks may cause problems in the future). Microsoft are pretty clear:
Microsoft documentation: Application.OnTime method (Excel)

Procedure must take no arguments
And, as you point out, the syntax is 'tricky'- and not checked by VBA at design time

>I am also not quite following what it is that the OP, jimpatel1993 , wants exactly

My assumption is that they have a webpage that perhaps has an inactivity timeout that results in a disconnection or logout that they are trying to avoid

User avatar
DocAElstein
4StarLounger
Posts: 545
Joined: 18 Jan 2022, 15:59
Location: Re-routing rivers, in Hof, Beautiful Bavaria

Re: Auto click link every 30 mins and repeat

Post by DocAElstein »

an argument is the actual value passed, a parameter is the definition of the expected argument.
Thx - I suppose it’s nit picking to a lot of people, but it helps me to get these straight , ( as I have no formal computer educations, ( and missed a lot of basic stuff :I am a relic from a social class hidden from the history books), imprecision in these word things tends to send me off track quite often and confuse me, when I guess it does others less so. . )

( Another word you just used sends me a bit wonky sometime when computer people use it - engine
I don’t know if that is a filler word used by computer people, and sounds good but means nothing. – like when I was growing up at the wrong end of the council estate, we had to use similar filler words in every second sentence, mostly 4 letter ones. It was like an identifying code or password to prove you were genuine in that situation and belonged there. If we didn’t use them, it could literally cost you your life, as not using them seemed to suggest you were a spy or infiltrator from the, to us, other side – the rich upper class people –those so called “working class” people from the better end of the council estate.
I don’t know if maybe words like engine have a similar effect in the mainstream forum computer community and that is where I have sometimes come a cropper in the past and used the wrong word and genuinely, seriously unintentionally, upset and annoyed people.
When your life, job/ career or general survival amongst others depends on you throwing in a filler word frequently it becomes a sort of instinct to do that , and you learn to do it normally, instinctively without thinking like in a sort of engine in idle.
The next time I want to genuinely innocently and politely tell someone to stop talking smart xxxx rubbish or I will kick the xxxxing xxxx out of him I will use the word engine instead. Sounds strange to me but maybe it will get me accepted a bit better.
Things along the lines of … don’t talk engineering rubbish , that’s a pile of engine, keep it up and I will kick the engines out of you …. – that last part sounds OK to me actually. Maybe I am picking up the language, slowly. :-) )

_.____

About managing to pass real arguments in the On-Time engines as if they should have parameters … I had missed that point about Procedure must take no arguments – a stupid oversight on my behalf– I am sure I passed that MS documentations on my On-Time Application Run ( engines ) experiments a few years back. That is, to me, interesting:- , so it was helpful for that head’s up, thx, I must think again about, in Particular, why , they should say that. I suppose if I was always going to use their latest Office versions I might start to be a bit worried about them saying that.
But I personally am less worried. - I want to try to standardise on their stable earlier versions. Then , if I am still here, move on to something else, most likely, ( unless MS buck their engineing ideas up).
So far it seems to work consistently, ( abusing their engineering engines) in all my versions and computers, and, as a bonus, works also, so far for me, in all the newest versions, which I only rarely use, - I only use them just for the sake of “keeping up with their newest (engines) ”. So for me I am OK to use it: Mostly for me it is for some very important personal projects:
I have some codings that have some unusual On-Time Application Run combinations ( using with reference full path syntax ) things that seem to 0pen very quickly and efficiently workbooks, ( only if they have to ). - I don’t know why, but they seem to open a workbook and carry out a macro in it quicker than doing the opening and running in the more socially acceptable way. ( something to do with exposing interfaces I think . I don’t know what that means either, but sounds good. I am going to do it a lot more , exposing things, I mean. ( I was born ugly. Cant do so much about that in a healthily honest way. But I worked hard to make the rest of body look good. If I take my clothes off I look good ) )

_._____

the OP, jimpatel1993 , wants exactly
…. My assumption is that they have a webpage that perhaps has an inactivity timeout that results in a disconnection or logout that they are trying to avoid

If that is the case, I have some coding here that
_ opens website pages in a few ways, and/ or
_ closes any browser very certainly and effectively. (not too sure about individual tabs only)

I use/ used** a code sometime to refresh a weather forecast page by doing the F5 by a send keys thing. ( I have heard smart people tell me that the send keys thing is dodgy, but I never had any problems Yet): **Since climate wandering and global warming I did not need it so much, but it did work well to keep a weather forecast page side up to date when I preferred not to physically touch anything for fear of messy wet cold stuff dropping off me and destroying my computer.
Another possibility is that perhaps he has been asked to do something more sinister, like make things look like viewed. I doubt if any of us know how to do that effectively anymore. Any web site where views have any significance have long since figured out a lot of different ways how to tell the difference between real views and automated repeated stuff, I expect.
I seriously don’t ever try to annoy. Maybe I am just the kid that missed being told about the King’s new magic suit, :(

User avatar
SpeakEasy
4StarLounger
Posts: 535
Joined: 27 Jun 2021, 10:46

Re: Auto click link every 30 mins and repeat

Post by SpeakEasy »


User avatar
DocAElstein
4StarLounger
Posts: 545
Joined: 18 Jan 2022, 15:59
Location: Re-routing rivers, in Hof, Beautiful Bavaria

Re: Auto click link every 30 mins and repeat

Post by DocAElstein »

Thx, I thought I did a quick Google but missed that – maybe I missed the word software – software engine is perhaps what its about, or what people mean and engine has just slipped in as a shorthand/ abbreviation
Another one – Life’s a Metaphoric stage, we play our part, and all that, providing and integrating functionality to the one that loads us, puts us on the stage or enWeds us, :-)
I think I was not far off, - it’s mostly a meaningless filler word, but the context can be critical. I guess that article can help me figure out when to let the word engine slip out, for example, to survive the evening if I accidentally land on the wrong Dinner table with a bunch of computer professionals.
The word and articles like that one exist to some exctent because in the communities they exist in it’s sometimes not permitted to use the correct words to explain things concisely and simply.
Its mostly a pile of embedded xxxx, a load of loaded xxxxxx, meaningless drivel to help computer things more clever sounding and complicated than they should be, and add seeming functionality where there ‘aint much. - just saying based on my experiences driven and opinions engine , I might have a piston short of full engine functionality.


_.___

I guess the simplified story with the On-Time with arguments is its OK and useful for a home user, but in a professional environment you might want to not use it as Microsoft clearly told you not to. I would suspect most likely the OP might be OK to use it. Depending on what he has in mind, passing arguments to use in the place he opens could be useful especially if those arguments are generated by something else in the meantime. **The advantage of On-Time is I guess that you could be doing other stuff in the application running it in the meantime:
**Originally I did not twig to why the On-Time was suggested here instead of a simple loop with Wait, as I use to keep my weather forecast rain radar page up to date on rainy days. I guess I am tying things up, whereas with the On-Time solution you are free to use most things normally including the Office application running the macro ?



I think I missed the potential for me of using this On-Time, especially with arguments, as I have some computers sitting around turned on most of the time.
, ….using the Hackery On-Time Run with embedded Arguments software engine, that could be a good title for one of my Naked YouTube videos. …

Today I think is the time to go power up or start building up the Xmas festivities engine..
I seriously don’t ever try to annoy. Maybe I am just the kid that missed being told about the King’s new magic suit, :(

User avatar
SpeakEasy
4StarLounger
Posts: 535
Joined: 27 Jun 2021, 10:46

Re: Auto click link every 30 mins and repeat

Post by SpeakEasy »

>software engine is perhaps what its about

Indeed. I mean, what else would software engineers be working on ... :wink:

User avatar
DocAElstein
4StarLounger
Posts: 545
Joined: 18 Jan 2022, 15:59
Location: Re-routing rivers, in Hof, Beautiful Bavaria

Re: Auto click link every 30 mins and repeat

Post by DocAElstein »

Some software engineers seem to know a bit about the hardware and some are even confident enough to put together a computer. So I might have thought it could mean some hardware thing in a computer, but I suppose it’s much more likely gonna be about software stuff, software things, software engines, software biscuits etc.
The context is important I guess, which with the engine stuff I came across would have been software usually I suppose.
_._____________________________________________________________


One last thing on the On-Time with arguments theme, just for completeness.
To do the thing with Parameters rather than arguments, ( using variables in the syntax rather than the values) , then it would be , as example like this

Code: Select all

 Public Sub Startyit()
Dim Nmbr As Long, Wrd As String
 Let Nmbr = 25: Let Wrd = "A Fursts Word"
 Application.OnTime Now + TimeValue("00:00:03"), "'ClickClock      " & Nmbr & "  ,   """ & Wrd & """        '"
End Sub
Public Sub ClickClock(ByVal ANumber As Long, ByVal AWord As String)
Debug.Print ANumber & "   " & AWord
    If Range("A1").Value2 = "Stop" Then Exit Sub
Dim Nmbr As Long, Wrd As String
 Let Nmbr = 25: Let Wrd = "A Paratum"
 Application.OnTime Now + TimeValue("00:00:03"), "'ClickClock    " & Nmbr & "  ,   """ & Wrd & """        '"
End Sub
That’s not really as clever or sirfistygated as it looks. All that is really doing is actually writing the values into the string that .. goes… or is put.. wherever it goes or is put. You can’t really send the variables as they die when the subroutine ends, which will always be before the scheduled thing starts. You are not Calling something so I guess there is no stack organised for such variables in this situation . At least that is my assumption, but I only just thought about that for the first time as I wrote it.
You do not have the required permissions to view the files attached to this post.
I seriously don’t ever try to annoy. Maybe I am just the kid that missed being told about the King’s new magic suit, :(

User avatar
SpeakEasy
4StarLounger
Posts: 535
Joined: 27 Jun 2021, 10:46

Re: Auto click link every 30 mins and repeat

Post by SpeakEasy »

>To do the thing with Parameters rather than arguments, ( using variables in the syntax rather than the values)

No, no! If we are going with the formal definitions, then these are still arguments. A parameter is a variable in a function/procedure definition. It is a placeholder and hence does not have a concrete value. An argument is a value passed during function/procedure invocation.

Code: Select all

Public Sub ExamplePart1()
    Dim arg1 As Long
    Dim arg2 As Double
    Dim arg3 As String
    Call ExamplePart2(arg1, arg2, arg3) ' three arguments passed
End Sub

Public Sub ExamplePart2(ByVal Param1 As Long, ByVal Param2 As Double, ByRef Param3 As String)
    ' do stuff
    MsgBox Param3 ' of course, now has a concrete value and is considered an argument if we pass to another sub/function ...
End Sub
Ok, and now you are considering using variables you hit one of the (various) limitations of the hack: how would you successfully pass an array? Or an object?

>You can’t really send the variables as they die when the subroutine ends
Sort of. In fact they never actually reach the subroutine. .OnTime (and .Run) actually evaluate the argument(s) and then pass those evaluated copies ByVal to the subroutine