これは、AutoHotKeyですべてのことを行うというあなたの質問には対処しません。私が提供しているのは、TamperMonkey FFまたはTamperMonkey Chromeでそれを行うための基本的なJavaScriptです。
このソリューションを使用する場合は、スケジュールされたタスクによってトリガーされるBatファイルを作成するだけです。あなたのバットファイルはあなたの望むURLであなたの好みのブラウザを起動し、TamperMonkeyは今日の日付を評価して、ログインする必要があるかどうかを決定します。これはJavascriptを使用しています。月は0〜11で表されます(通常は1〜12ではありません)。なぜnew Date(2017, 11, 25)
がDecember 25 2017
で、November 25 2017
ではないのですか。
//
//TamperMonkey script
//
var workDays = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday"];//set your working days
var holidays = [new Date(2017, 11, 25).setHours(0, 0, 0, 0), new Date("2017", "11", "6").setHours(0, 0, 0, 0)];//set your holidays
var today = new Date();//get today's date
/*
This function will return the name of the day
*/
function getDayName(dateStr, locale) {
var date = new Date(dateStr);
return date.toLocaleDateString(locale, { weekday: 'long' });
}
/*
If today's day is in the workDays array, and today is not in the hollidays array
Then login
Else Don't log in
*/
if (workDays.indexOf(getDayName(today, "en-US")) > -1 && holidays.indexOf(new Date(today).setHours(0, 0, 0, 0)) == -1) {
console.log("working today");
document.getElementById("user_login").value = "your username";//enter your username
document.getElementById("user_pass").value = "your pwd";//enter your password
document.getElementById("wp-submit").click();//click the login button
}
else {
console.log("not working today");
}
をフォローアップ。欠落している部分はTaskSchedulerだけです。だから、私はFireFox @ www.google.comを起動するバットファイルです。ページが読み込まれると、TamperMonkeyが引き継いで今日の日付を評価します。今日の日付が良い日であれば、テキストフィールドにテキストが自動的に挿入され、ボタンがクリックされます。
私は、そのファイルには、 "GetMeThere.bat" batファイルを作成し、私が書いた:
を "C:\プログラムファイル(x86の)\ Mozilla Firefoxの\ firefox.exeをする"「www.google。 com」
TamperMonkeyでは、私は新しいスクリプトを作成しました。これはその中のすべてです。
// ==UserScript==
// @name SearchOnGoogleOnWorkDays
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://www.google.ca*
// @grant none
// ==/UserScript==
//
//TamperMonkey script
//
var workDays = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday"];//set your working days
var holidays = [new Date(2017, 11, 25).setHours(0, 0, 0, 0), new Date("2017", "11", "6").setHours(0, 0, 0, 0)];//set your holidays
var today = new Date();//get today's date
/*
This function will return the name of the day
*/
function getDayName(dateStr, locale) {
var date = new Date(dateStr);
return date.toLocaleDateString(locale, { weekday: 'long' });
}
/*
If today's day is in the workDays array, and today is not in the hollidays array
Then login
Else Don't log in
*/
if (workDays.indexOf(getDayName(today, "en-US")) > -1 && holidays.indexOf(new Date(today).setHours(0, 0, 0, 0)) == -1) {
console.log("working today");
//document.getElementById("user_login").value = "your username";//enter your username
//document.getElementById("user_pass").value = "your pwd";//enter your password
//document.getElementById("wp-submit").click();//click the login button
document.getElementById("lst-ib").value = "search for this";
var els = document.getElementsByName("btnK");
console.log(els);
if(els != null){els[0].click();}
}
else {
console.log("not working today");
}
に注意してください、私はコンセプトを証明するために非常に迅速に一緒にこれを置きます。この// @match https://www.google.ca*
はプロダクションコードには広すぎるため、私の公開TamperMonkeyスクリプトは無限の検索ループに入ります。しかし、それはコンセプトが機能することを証明します。私がbatファイルをダブルクリックすると、Firefoxがwww.google.comで起動し、TamperMonkeyが自動的に検索を行います。
あなたのスクリプトのTaskSchedulerを使ってスクリプトをトリガーし、今日の日付をプルして、今日の日が月曜日と金曜日の間で、12月25日でないかどうかを調べるためにそれを調べてください。あなたのログインスクリプトを使用してください。さもなければ、明日@ 9amを見てください。[日付の計算](https://autohotkey.com/board/topic/72923-calculate-dates/) –
ちょうど良い日です。あなたはTaskScheduler/Bat/Firefox/TamperMonkeyまたは同様のカクテルを使って同じことを達成することができます。タスクスケジューラがBatファイルをトリガーし、batファイルがあなたの望むURLでFirefoxを起動すると、今日の日が適格であればあなたのTamperMonkeyスクリプトがログインを処理します。 –
TaskSchedulerでは平日のみを設定できますが、特定の例外は設定できません。 – HaveSpacesuit