LoginSignup
0
0

More than 1 year has passed since last update.

ゲーム開始/終了時のスクリプト

Last updated at Posted at 2022-09-21

概要

普段ゲーム開始などで用意するスクリプト集 メモ

開始

処理内容

  • ゲーム起動に必要なショートカットを起動。
  • Windowsサウンド変更 スピーカーからヘッドセットへ変更。
  • 最後にpythonで自動tweetを行う内容を添付。
game開始.bat
chcp 65001
start "" "C:\****\デスクトップ\****.exe - ショートカット.lnk"
start "" "C:\****\デスクトップ\ヘッドセット設定.lnk"
timeout 5
start "" "C:\****\デスクトップ\****.url"
timeout 30
start /min "" "C:\****\デスクトップ\****.exe - ショートカット.lnk"
start chrome.exe --window-position=1920,675 --window-size=930,350
timeout 3
start "" "C:\****\ドキュメント\programming\game_tweet.py"

終了

処理内容

  • ゲーム終了に必要なショートカットを起動。
  • Windowsサウンド変更 ヘッドセットからスピーカーへ変更。
  • 最後にpythonで自動tweetを行う内容を添付。
    • 終了時にFirefoxの指定URLページを起動。
game終了.bat
chcp 65001
start "" "C:\****\デスクトップ\スピーカー.lnk"
taskkill /f /im ****.exe /T
taskkill /f /im ****.exe /T
taskkill /f /im ****.exe /T
taskkill /f /im ****.exe /T
taskkill /im chrome.exe
taskkill /im taskmgr.exe
timeout 3
start "" "C:\****\ドキュメント\programming\game_tweet.py"

game_tweet.py について

主に下記の記事を参考にして自動ツイートに成功。

game_tweet.py
import tweepy
import time
import schedule
import open_mv

if __name__ == '__main__':
    # 取得したアクセスキーたちをセット。
    api_key='*********'
    api_key_secret='*********'
    access_token='*********'
    access_token_secret='*********'

    auth = tweepy.OAuthHandler(api_key,api_key_secret)
    auth.set_access_token(access_token,access_token_secret)

    number = input('1:st_message,2:end_message,3:none: ')
    number = int(number)

    #2の時にopen_mv.browser_opのモジュール起動
    if number == 1:
        api = tweepy.API(auth)
        message = message = "今からgame開始"
        api.update_status(message)
    elif number == 2:
        api = tweepy.API(auth)
        message = "今日のgame終了"
        api.update_status(message)
        open_mv.browser_op()
    else:
        print("none")
    exit
open_mv.py
import time
import win32gui
import win32.lib.win32con as win32con
import subprocess
import os

def browser_op():
    os.system("taskkill /im firefox.exe")
    time.sleep(1)

    # ファイルパスを指定して変数へ代入
    firefox = r"C:\Program Files\Mozilla Firefox\firefox.exe"
    subprocess.Popen([firefox,"https://www.yahoo.co.jp/"])

    # アプリを右画面で開く
    hwnd = win32gui.GetForegroundWindow()
    win32gui.MoveWindow(hwnd, 2000, 50, 1600, 900, True)
    time.sleep(2)
    win32gui.ShowWindow(hwnd, win32con.SW_MAXIMIZE) 

サウンドデバイスの変更

changeSoundDevice.js
//https://jutememo.blogspot.com/2012/08/windows.html
  
var wait = function(title){
    do {
	WScript.Sleep(100);
    } while(!WshShell.AppActivate(title));
};

var WshShell =  WScript.CreateObject("WScript.Shell");
WshShell.Run("control mmsys.cpl");
wait("サウンド")
WshShell.SendKeys("{DOWN " + 
	WScript.Arguments.item(0) +
	"}%{s}{TAB 3}{ENTER}");
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0