2017-12-06 22 views
0

WordPressのダッシュボードにログインするために正しく機能しているAutoHotKeyスクリプトがあります。Schedule AutoHotKey Script

私はこのスクリプトを実行するスケジュールを追加したい:

  • を実行し、このスクリプトは、午前9時、土曜日と日曜日
  • 除く
  • 毎日が特定の日付(例を除く:今年12クリスマスの日に/ 17分の25)ここ

は、現在のコード

; Start script, open website login URL 
Run http://www.digitango.com/wp-login.php 

; Wait for page to fully load 
Sleep, 2000 

; Click Username Field 
Click, 850, 430 

; Selected all items in input field 
Send, ^{a} 

; Remove all from input field 
Send, {Del} 

; Enter User Name 
Send, username 

; Click Password Field 
Click, 850, 510 

; Selected all items in input field 
Send, ^{a} 

; Remove all from input field 
Send, {Del} 

; Enter Password 
Send, password 

; Click Login Button 
Click, 1075, 560 

; Wait f 
Sleep, 2000 

; Notify script has started 
MsgBox, You successully logged in automatically! 

; Enable exit script by hitting escape key 
Esc::ExitApp 

; End Script 
Return 
あります
+2

あなたのスクリプトのTaskSchedulerを使ってスクリプトをトリガーし、今日の日付をプルして、今日の日が月曜日と金曜日の間で、12月25日でないかどうかを調べるためにそれを調べてください。あなたのログインスクリプトを使用してください。さもなければ、明日@ 9amを見てください。[日付の計算](https://autohotkey.com/board/topic/72923-calculate-dates/) –

+1

ちょうど良い日です。あなたはTaskScheduler/Bat/Firefox/TamperMonkeyまたは同様のカクテルを使って同じことを達成することができます。タスクスケジューラがBatファイルをトリガーし、batファイルがあなたの望むURLでFirefoxを起動すると、今日の日が適格であればあなたのTamperMonkeyスクリプトがログインを処理します。 –

+1

TaskSchedulerでは平日のみを設定できますが、特定の例外は設定できません。 – HaveSpacesuit

答えて

1

これは、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が自動的に検索を行います。

+0

私はこれを試してみるつもりですが、もっと良い解決策かもしれないと思います。 –

+0

Batファイルの設定方法を教えてくれますか? –

+0

@HeckRaiser、はい、私はそれをローカルで書き、テストしてから、私は答えを更新します。 –