我有一个Chrome扩展程序,可通过import java.util.Scanner;
public class CreditCardInterest {
public static void main(String[] args) {
// Variable Declarations
Scanner k = new Scanner(System.in); // create a keyboard object
System.out.println("Credit Card Interestn" + "--------------------------- \n");
System.out.println("This program calculates how much interest you need to pay on your credit card \n" + "balance.");
String answer;
double balance;
int fixedcycle = 31;
int cycle;
double payment;
double interest;
double result;
System.out.println("Did you pay your balance in full and on time?");
System.out.print("(Please Answer Yes or No): ");
answer = k.nextLine();
if (answer.equalsIgnoreCase("Yes")) {
System.out.println("\nCongratulations on paying the full amount!\n" + "No interest will be charged on your card.\n" + "Thank you for using the Credit Card Interest Calculator!\n" +
"Your system will now exit");
System.exit(0);
}
if (answer.equalsIgnoreCase("No")) {
System.out.print("Please enter the previous balance on your credit card: ");
balance = k.nextDouble();
System.out.print("How many days before the end of the cycle did you pay?: ");
cycle = k.nextInt();
System.out.print("How much was paid then?: ");
payment = k.nextDouble();
System.out.print("What is the interest rate of your credit card?: ");
interest = k.nextDouble();
System.out.println("");
if (balance > 0 && cycle > 1 && cycle < 31 && payment <= balance && payment > 0 && interest == 17 && interest == 18.5) {
result = ((payment * fixedcycle) - (balance * cycle)) / fixedcycle;
System.out.println("The interest charge on your credit card is $" + result);
} else {
System.out.println("You entered some Invalid Data!!!\n" + "No Interest calculation will be provided\n\n");
System.out.println("Balance: " + balance);
System.out.println("This value should be positive and cannot be zero.\n");
System.out.println("Day of the billing cycle:" + cycle);
System.out.println("This value should be between 1 and 31.\n");
System.out.println("Payment amount: " + payment);
System.out.println("This value should be positive and less than or equal to the balance.\n");
System.out.println("Annual interest rate: " + interest);
System.out.println("This value should be either 17.0 or 18.5.\n\n");
}
}
}
}
与自动应用程序进行交互。
我使用以下代码从Autoit获取消息到扩展名:
nativeMessaging
然后我使用此代码尝试从扩展程序向Autoit发送消息:
var port = chrome.runtime.connectNative('com.my_company.my_application');
port.onMessage.addListener(function(msg) {
console.log("Received" + msg);
});
但是,如何让Autoit应用程序评估从扩展程序发送的消息?