[PYTHON] Continue! Remote work sabotage corps with pyAutoGUI!

Today's troubles

Panda-san, Teams is leaving at this, please do something about it.

People People People People > Exfoliation <  ̄Y^Y^Y^Y ̄

Background

The previous article was a source created during a chat (LINE) with a former client. .. I didn't expect a strong man to use it so close ...!

"I'm leaving." "Work ..." "Because you don't do remote work!"

That's why Microsoft Teams (a standard chat tool in the company) is talking about avoiding the exit display. I wish I could surf the internet on that device.

This solution

The solution this time is "how to keep Teams in contact". Since I'm on the go, I'll write some candidates for ways I can think of (after verification is back).

1. You should open Teams on your smartphone

① Download the app version of Teams and set up your own account ② Set the automatic lock of the smartphone to "None" ③ Open the app version of Teams and put it on the side (charging)

Microsft Teams can easily stay "contactable" with this procedure. Please note that ** you cannot be "contactable" unless the app is active **. You can't just start it in the background and play a game on your smartphone. I think it's okay for people who have a smartphone that they don't normally use ... or want to sleep without touching the smartphone. I don't know (whatever the company's evaluation).

2. Make it look like you are operating using Python (pyAutoGUI)

In Microsoft Teams, I think that the display while leaving was left for 5 minutes. Even at work, I often leave it unattended. At that time, trying to restore

--Moving the cursor on the mouse / touch panel --Moving the cursor with the keyboard (arrow keys, tab key)

When I tried to move it, it happened that it remained "away" and did not change. The method to surely cancel the absentee display at this time is ** key input operation **. So I think we should let Python do the same thing.

sample2.py


import pyautogui as pg
import time
try:
    while True:
        time.sleep(180)

        #open chrome
        pg.hotkey('win','r')
        pg.typewrite('chrome.exe')
        pg.press('enter')
        time.sleep(5)

        #Search for string test
        pg.typewrite('test')
        pg.press('enter')
        time.sleep(5)

        #close the window
        pg.hotkey('alt','f4')

except KeyboardInterrupt:
    print('Work')

The explanation is as the comment in the source. I just changed the previous mouse operation to "Open Chrome, search for the string" test "and close it." A waiting time is set for each process so that [Alt] + [F4] does not close another one (the time is appropriate, so please adjust while starting).

3. I mean, should I make it "contactable"?

I was thinking while writing the code for 2 ... Isn't it just a matter of opening Microsoft Teams and making the status "contactable"?

In other words, this is what it is.

sample3.py


import pyautogui as pg
import time
try:
    while True:
        time.sleep(180)

        #Open Teams
        pg.hotkey('win','r')
        pg.typewrite('XXX\Teams.exe') #The startup file requires the full path
        pg.press('enter')
        time.sleep(10)

        #Change status to contactable
        pgui.press('/')
        pgui.typewrite('available')
        pg.press('enter')

except KeyboardInterrupt:
    print('Work')

The explanation is also as the comment in the source. The reason why the `` `time.sleep``` waiting for processing is taken as long as 10 seconds is because I felt that it would take a long time to start up. The Microsft Teams desktop app is registered in the startup by default when installed, so I don't think it will take that long to just activate it (it shouldn't have been double-launched ...)

at the end

When I asked the former client who started it in the first place, "Did you move it?", He said, "I'm not using it because it's a barre." Did you really move such a thing? .. If you don't have a job and you're free, you can create a job ...

Or rather, if I wrote such a recommended article for skipping, I think I would be sick of it, right?

Recommended Posts

Continue! Remote work sabotage corps with pyAutoGUI!
Japanese input with pyautogui