How to stay always “Available” in Microsoft Teams with Excel

by Misc2 comments

Why?

First it was a private joke, with this article it’s now a public joke.

Our client switched from Skype to Teams and it was a very cool improvement. My colleagues told me with a bit of fun: “Teams is cool, but you can’t change the time before appearing away!”. And it’s true, we can’t! Somebody said, “If you install a software who will click randomly on your screen, you will not appear away anymore”. Yes,.. but our software policy does not allow us to install anything on our computers.

It gave me an idea! Thanks to our very good old friend, Excel! People will say “Lazy is smart”, Arnaud is “funny” or any other reason. But I had fun with Excel and his perfect VBA editor.

My colleague Isabelle (and also Maslow) will say :

https://en.wiktionary.org/wiki/if_all_you_have_is_a_hammer,_everything_looks_like_a_nail

My hammer is Excel and Code.. I agree.. (nail or snail.. it’s just a “s” who is missing)

I created a small excel sheet who will loop until you ask it to finish and will move your mouse cursor every 5 seconds.

My joy is shared between.

“I’m the Microsoft BI guy who uses Microsoft Office and VBA code to do a joke”.

and

“People will see me as a very lazy guy!! isn’t the name of his website!?!”.

Anyway, if you read this article, then it’s because I think you will pick the first idea. I’m I wrong? šŸ™‚

Where can you download it?

You can download the excel sheet on my github repo.

(If you want your own excel sheet, the code is also available at the end of this post)

How does it look like?

This is how it looks in Excel. You can start the timer by clicking on the start button or CTRL + l (like lazysnail) or start manually the macro named “DoNotSleep”.

To stop the timer, you have to press any key.

Do you have the VBA code?

If you are curious and want to build your own Excel, let’s copy the following VBA code:

Public Declare Function SetCursorPos Lib "user32" (ByVal x As Long, ByVal y As Long) As Long
Public Declare Sub mouse_event Lib "user32" (ByVal dwFlags As Long, ByVal dx As Long, ByVal dy As Long, ByVal cButtons As Long, ByVal dwExtraInfo As Long)
Public Const MOUSEEVENTF_LEFTDOWN = &H2
Public Const MOUSEEVENTF_LEFTUP = &H4
Public Const MOUSEEVENTF_RIGHTDOWN As Long = &H8
Public Const MOUSEEVENTF_RIGHTUP As Long = &H10

Sub DoNotSleepPlease()

Dim i As Integer

For i = 1 To 9999
    'For Info, number of iteration
    'Cells(1, 1) = i
    If Cells(3, 5) = "" Then
        SetCursorPos 200, 200 'x and y position
        mouse_event MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0
        mouse_event MOUSEEVENTF_LEFTUP, 0, 0, 0, 0
        WaitPlease
        
        
        SetCursorPos 300, 300 'x and y position
        mouse_event MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0
        mouse_event MOUSEEVENTF_LEFTUP, 0, 0, 0, 0
        WaitPlease
        
        SetCursorPos 400, 400 'x and y position
        mouse_event MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0
        mouse_event MOUSEEVENTF_LEFTUP, 0, 0, 0, 0
        WaitPlease
        
        SetCursorPos 500, 500 'x and y position
        mouse_event MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0
        mouse_event MOUSEEVENTF_LEFTUP, 0, 0, 0, 0
        WaitPlease
    Else
        Exit For
    End If
    Next i
End Sub


Sub WaitPlease()
    Dim sngWaitEnd As Single
    sngWaitEnd = Timer + 5
    Do
      DoEvents
      Cells(3, 3).Value = Timer
    Loop Until Timer >= sngWaitEnd
End Sub

2 Comments

  1. Edouard

    Arnaud, this is amazing. I have no need of such tool as Iā€™m always moving my cursor anyway… but might send it to a few friends!

    Reply
  2. Emelia Johansson

    I have issues getting this to work in my 64 bit system. I get the following error code. Could you possible change the script to work for both 32 and 64?

    Compile error:
    The code in this project must be updated for use on 64-bit systems.
    Please review and update Declare statements and then mark them with the PtrSafe attribute.

    Reply

Submit a Comment

Your email address will not be published.

Stay Up To Date!
Join the newsletter

Arnaud GASTELBLUM

Pin It on Pinterest

Shares
Share This