當前位置:首頁 » 編程軟體 » 腳本程序計算器

腳本程序計算器

發布時間: 2022-04-16 08:50:39

⑴ 用python操作Windows的計算器。

pyhook可以抓到鍵。

不過這里只需要消息就可以了,win32api中的windows的message

使用vc中的消息 工具,抓鍵盤消息。然後再把這個消息包裝一下用pywin32中的API發送過去。

我以前用pyhook加pywin32, 控制過一個游戲,做外掛。

也用pywin32的com介面控制過excel

⑵ 怎樣用shell腳本寫一個簡單的計算器

while (true); do
read -p "輸入算式: " var
[[ $var == q ]] && break || echo "等於: "$(echo "scale=2;$var"|bc)
done
輸入算式就能給出結果,輸入q退出

⑶ 剛學shell腳本寫了個小 計算器,加減除都可以,乘法不行,哪兒錯了

你的問題在:elif [ $fangfa = " \* " ]; 這句並不能判斷到「*「乘號;
正確的結果如下:
#!/bin/bash
echo "first number"
read a
echo "fangfa"
read fangfa
echo "second number"
read b
if [ "$fangfa" = "+" ];then
echo $(($a+$b))
elif [ "$fangfa" = "-" ];then
echo $(($a-$b))
elif [ "$fangfa" = "*" ];then
echo $(($a*$b))
elif [ "$fangfa" = "/" ];then
echo $(($a/$b))
fi
===============================================
腳本優化版本:
#!/bin/bash

read -p "input first number: " num1
read -p "input operator: " operator
read -p "input second number: " num2

if [ "$operator" == "+" ];then
echo " num1 + num2 = $(($num1+$num2))"
elif [ "$operator" == "-" ];then
echo "num1 - num2 = $(($num1-$num2))"
elif [ "$operator" == "*" ];then
echo "num1 * num2 = $(($num1*$num2))"
elif [ "$operator" == "/" ];then
echo "num1 / num2 = $(($num1/$num2))"
fi

⑷ 求flash腳本編寫 做簡易計算器

已發消息給你,請查看。

⑸ 在ASP中用VB腳本語言怎麼做計算器

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>Calculate</title>
<script language="VBSCRIPT">
Function Show(m)
If (Myform.Expression.Value = "" AND InStr(". + - * / ",m)) Then
Myform.Expression.Value = ""
ElseIf (InStr("+ - * / . ",Right(Myform.Expression.Value,1)) And InStr("+ - * / ",m)) Then
ElseIf (m = ".") Then
If (InStr("+ - * / . ",Right(Myform.Expression.Value,1))) Then
ElseIf ((InstrRev(Myform.Expression.Value,".") > InstrRev(Myform.Expression.Value,"+")) And (InstrRev(Myform.Expression.Value,".") > InstrRev(Myform.Expression.Value,"-")) And (InstrRev(Myform.Expression.Value,".") > InstrRev(Myform.Expression.Value,"*")) And (InstrRev(Myform.Expression.Value,".") > InstrRev(Myform.Expression.Value,"/"))) Then
Else
Myform.Expression.Value = Myform.Expression.Value + m
End If
Else
Myform.Expression.Value = Myform.Expression.Value + m
END If

End Function

Function Sqrt()
If (Myform.Expression.Value = "") Then
Myform.Expression.Value = ""
ElseIf (InStr(". + - * / ",Right(Myform.Expression.Value,1))) Then
Else
Myform.Expression.Value = Eval(Myform.Expression.Value)^2
End If

End Function
Function Result()
If (Myform.Expression.Value = "") Then
Myform.Expression.Value = ""
ElseIf (InStr(". + - * / ",Right(Myform.Expression.Value,1))) Then
Else
Myform.Expression.Value = Eval(Myform.Expression.Value)
End If
End Function
Function Clean()
Myform.Expression.Value = ""
End Function
</script>
<style type="text/css">
<!--
.style5 {font-size: 18px}
-->
</style>
</head>
<body bgcolor="#ffffee" text=#000000>
<form name="myform" method="post" action="">
<div align="center">
<table bgcolor="#C0e0ff" width="214" height="245" border="4">
<tr>
<th width="206" scope="col"><H2><font color="#0000A0"> 計算器 </font></H2></th>
</tr>
<tr>
<th height="36" scope="col"><table width="200" border="1">
<tr>
<td colspan="4"><div align="center">
<input name="expression" type="text" value="" size="28" maxlength="28" >
</div></td>
</tr>
<tr>
<td><div align="center">
<INPUT TYPE="button" id="seven"
onClick="Show('7')" VALUE=" 7 ">
</div></td>
<td><div align="center">
<INPUT TYPE="button" VALUE=" 8 "
onClick="Show('8')">
</div></td>
<td><div align="center">
<INPUT TYPE="button" VALUE=" 9 "
onClick="Show('9')">
</div></td>
<td><div align="center">
<INPUT TYPE="button" VALUE=" / "
onClick="Show('/')">
</div></td>
</tr>
<tr>
<td><div align="center">
<INPUT TYPE="button" VALUE=" 4 "
onClick="Show('4')">
</div></td>
<td><div align="center">
<INPUT TYPE="button" VALUE=" 5 "
onClick="Show('5')">
</div></td>
<td><div align="center">
<INPUT TYPE="button" VALUE=" 6 "
onClick="Show('6')">
</div></td>
<td><div align="center">
<INPUT TYPE="button" VALUE=" * "
onClick="Show('*')">
</div></td>
</tr>
<tr>
<td><div align="center">
<INPUT TYPE="button" VALUE=" 1 "
onClick="Show('1')">
</div></td>
<td><div align="center">
<INPUT TYPE="button" VALUE=" 2 "
onClick="Show('2')">
</div></td>
<td><div align="center">
<INPUT TYPE="button" VALUE=" 3 "
onClick="Show('3')">
</div></td>
<td><div align="center">
<INPUT TYPE="button" VALUE=" - "
onClick="Show('-')">
</div></td>
</tr>
<tr>
<td><div align="center">
<INPUT TYPE="button" VALUE=" 0 "
onClick="Show('0')">
</div></td>
<td><div align="center">
<INPUT TYPE="button" VALUE=" . "
onClick="Show('.')">
</div></td>
<td><div align="center">
<input type="button" value="sqr"
onClick="sqrt()">
</div></td>
<td><div align="center">
<input type="button" value=" + "
onClick="Show('+')">
</div></td>
</tr>
<tr>
<td colspan="2"><div align="center">
<INPUT TYPE="button" VALUE=" AC "
onClick="clean()">
</div></td>
<td colspan="2"><div align="center">
<INPUT TYPE="button" VALUE=" = "
onClick="result()">
</div></td>
</tr>
</table></th>
</tr>
</table>

</div>
</form>
</body>
</html>

⑹ 利用javaScript腳本語言編寫一個簡單的「網頁計算器」

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>無標題文檔</title>
<script language="javascript">
function jsq(fh)
{
var num1,num2;
num1=parseFloat(document.form1.text1.value);
num2=parseFloat(document.form1.text2.value);
if(fh=="+")
document.form1.text3.value=num1+num2;
if(fh=="-")
document.form1.text3.value=num1-num2;
if(fh=="*")
document.form1.text3.value=num1*num2;
if(fh=="/")
if(num2!=0)
{
document.form1.text3.value=num1/num2;
}
else
{
alert ("除數不能為零!")
}
}
</script>
</head>

<body>
<form id="form1" name="form1" method="post" action="">
<label>
<input name="text1" type="text" id="text1" />
</label>
<p>
<label>
<input name="text2" type="text" id="text2" />
</label>
</p>
<p>
<label>
<input name="Button1" type="Button" id="Button1" value="+" onClick="jsq('+')">
<input name="Button2" type="Button" id="Button2" value="-" onClick="jsq('-')"/>
<input name="Button3" type="Button" id="Button3" value="*" onClick="jsq('*')"/>
<input name="Button4" type="Button" id="Button4" value="/" onClick="jsq('/')"/>
</label>
</p>
<p>
<label>
<input name="text3" type="text" id="text3" />
</label>
</p>
</form>
</body>
</html>

⑺ 求高手幫忙,用javascript腳本語言編寫個最簡單的計算器,如圖所示

Calculator.java:
import java.awt.*;
import java.awt.event.*;
import java.lang.*;
import java.applet.*;
public class Calculator extends Applet implements ActionListener{
Panel buttonPanel;
TextField tf; //用於顯示輸入的數字的文本框
Button b0,b1,b2,b3,b4,b5,b6,b7,b8,b9,bDot,bPlus,bSub,bDiv,bMulti,bEqual; //按鍵
String onDisplay=""; //顯示在文本框中的字元串
boolean isDotPressed=false; //按鍵'.'是否被按下
float operand; //通過按鍵輸入的數
float operand1,operand2;//operand1和operand2為計算用的操作數
char operator; //計錄所用的操作符
float result; //計算結果
int times=1; //小數點後有幾位的10次方冪
public void init(){
setLayout(new BorderLayout(5,5));
tf=new TextField(30);
add(tf,BorderLayout.NORTH);
buttonPanel=new Panel();
buttonPanel.setLayout(new GridLayout(4,4,5,5));
add(buttonPanel,BorderLayout.CENTER);
//下面依次把按鈕添加上去

b1=new Button("1");
buttonPanel.add(b1);
b1.addActionListener(this);
b1.setActionCommand("1");

b2=new Button("2");
buttonPanel.add(b2);
b2.addActionListener(this);
b2.setActionCommand("2");

b3=new Button("3");
buttonPanel.add(b3);
b3.addActionListener(this);
b3.setActionCommand("3");

bPlus=new Button("+");
buttonPanel.add(bPlus);
bPlus.addActionListener(this);
bPlus.setActionCommand("+");

b4=new Button("4");
buttonPanel.add(b4);
b4.addActionListener(this);
b4.setActionCommand("4");

b5=new Button("5");
buttonPanel.add(b5);
b5.addActionListener(this);
b5.setActionCommand("5");
b6=new Button("6");
buttonPanel.add(b6);
b6.addActionListener(this);
b6.setActionCommand("6");

bSub=new Button("-");
buttonPanel.add(bSub);
bSub.addActionListener(this);
bSub.setActionCommand("-");

b7=new Button("7");
buttonPanel.add(b7);
b7.addActionListener(this);
b7.setActionCommand("7");

b8=new Button("8");
buttonPanel.add(b8);
b8.addActionListener(this);
b8.setActionCommand("8");

b9=new Button("9");
buttonPanel.add(b9);
b9.addActionListener(this);
b9.setActionCommand("9");

bMulti=new Button("*");
buttonPanel.add(bMulti);
bMulti.addActionListener(this);
bMulti.setActionCommand("*");

b0=new Button("0");
buttonPanel.add(b0);
b0.addActionListener(this);
b0.setActionCommand("0");

bDot=new Button(".");
buttonPanel.add(bDot);
bDot.addActionListener(this);
bDot.setActionCommand(".");

bEqual=new Button("=");
buttonPanel.add(bEqual);
bEqual.addActionListener(this);
bEqual.setActionCommand("=");

bDiv=new Button("/");
buttonPanel.add(bDiv);
bDiv.addActionListener(this);
bDiv.setActionCommand("/");

}

public void actionPerformed(ActionEvent e){
String str=e.getActionCommand();
char b=str.charAt(0);
switch(b){
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9': onDisplay+=b;
operand=operand*10+Integer.parseInt(str);
if(isDotPressed) times*=10;
tf.setText(onDisplay);
break;
case '.': onDisplay+=b;
isDotPressed=true;
tf.setText(onDisplay);
break;
case '+':
case '-':
case '*':
case '/': operator=b;
operand1=operand/times;
System.out.println(operand1);
onDisplay="";
times=1;
isDotPressed=false;
operand=0;
break;
case '=': operand2=operand/times;
System.out.println(operand2);
switch(operator){
case '+': result=operand1+operand2;break;
case '-': result=operand1-operand2;break;
case '*': result=operand1*operand2;break;
case '/': result=operand1/operand2;break;
}
tf.setText(float.toString(result));
onDisplay="";
times=1;
isDotPressed=false;
operand=0;
break;
}
}
}

Calculator.html:
<html>
<applet code="Calculator.class" width=250 height=250>
</applet>
</html>

⑻ 如何用js做一個簡易計算器

js做一個簡易計算器具體如下:

  • <html>

  • <head>

  • <title>js運算</title>

  • <boby>

  • <table>

  • <tr>

  • <td>第一個數</td>

  • <td><input type="text" id="onesum"></td>

  • </tr>

  • <tr>

  • <td>運算符號</td>

  • <td><input type="text" id="fh"></td>

  • </tr>

  • <tr>

  • <td>第二個數</td>

  • <td><input type="text" id="twosum"></td>

  • </tr>

  • <tr>

  • <td>計算結果</td>

  • <td><input type="text" id="sum"></td>

  • </tr>

  • <tr>

  • <td colspan="2"><input type="button" value=" 計算 " onclick="js()"></td>

  • </tr>

  • <table>

  • <script>

  • function js(){

  • var num1=document.getElementById("onesum").value;

  • var num2=document.getElementById("twosum").value;

  • var fh=document.getElementById("fh").value;

  • var sum=0;

  • nu

  • m1=Number(num1);

  • num2=Number(num2);

  • if(fh=='+')

  • {

  • sum=num1+num2;

  • }

  • else if(fh=='-')

  • {

  • sum=num1-num2;

  • }else if(fh=='*')

  • {

  • sum=num1*num2;

  • }else if(fh=='/')

  • {

  • sum=num1/num2;

  • }

  • //alert(sum);

  • document.getElementById("sum").value=sum;

  • }

  • </script>

  • </boby>

  • </html>

⑼ 易語言製做計算器

呵呵,這個其實沒這么麻煩,
易語言
裡面就有這樣的組件可以利用:1.先在擴展組件裡面找到腳本組件並添加2.添加兩個編輯框(必須的)3.添加一個按鈕(沒按鈕怎麼行?)4.些入代碼,代碼如下:
.
子程序

_按鈕1_被單擊
編輯框2.內容

腳本組件1.計算表達式
(編輯框1.內容)
如果可以使用,請採納,謝謝。

⑽ 用JS腳本實現網頁計算器!!求代碼!求高手!!!!

C#的要不。。。
C#軟體中也能做js

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication2
{
public partial class 計算機 : Form
{
double Num1 = 0;//這三行是考慮計算時候要用的
double Num2 = 0;//這三行是考慮計算時候要用的

string op = "";//這三行是考慮計算時候要用的

public 計算機()
{
InitializeComponent();
}

private void btnNum1_Click(object sender, EventArgs e)
{
if (txtResult.Text != "")
{
double temp = double.Parse(txtResult.Text);//這個是做開平方的。。。
temp = Math.Sqrt(temp);
txtResult.Text = temp.ToString();

}
}

private void button6_Click(object sender, EventArgs e)
{
if (txtResult.Text != "")
{

double temp = double.Parse(txtResult.Text);//這個是那個「階乘鍵的」用的是「!」標記。
double factor = 1;
for (int i = 1; i <= temp; i++)
factor = factor * i;
txtResult.Text = factor.ToString();

}
}

private void btnNum1_Click_1(object sender, EventArgs e)
{
Button btn = sender as Button;//這個是第一步:要在計算器中輸入數字的。。。
txtResult.Text += btn.Text;
}

private void btnNum3_Click(object sender, EventArgs e)
{
if (txtResult.Text != "")
{
double temp = double.Parse(txtResult.Text);//這個是那個「正弦函數」。。
temp = Math.Sin(temp);
txtResult.Text = temp.ToString();
}

}

private void btnPoint_Click(object sender, EventArgs e)
{
if (txtResult.Text == "")
{
txtResult.Text = "0.";//這個是「小數點」問題。。。要考慮到:1、一串數字中不能出現兩個小數點。。2.第一個輸入小數點時問題
}

else
{
if (txtResult.Text.IndexOf(".") == -1)
{
txtResult.Text += ".";

}

}
}

private void btnNum0_Click(object sender, EventArgs e)
{
Button btn = sender as Button;//這是數字「0」的問題。。首先不能第一個為0.。。
if (txtResult.Text == "0")
{
txtResult.Text = btn.Text;
}
else
{
txtResult.Text += btn.Text;
}
}

private void btnAdd_Click(object sender, EventArgs e)
{
Button btn = sender as Button;//這是解決當第一個按「+」號時程序出錯的狀況。。。
if (txtResult.Text != "")
Num1 = double.Parse(txtResult.Text);
op = btn.Text;
txtResult.Text = "";
}

private void btnCalculate_Click(object sender, EventArgs e)
{
double result = 0;
Num2 = double.Parse(txtResult.Text);/////這是處理「=」的問題。。。不過還有些不足。。
switch (op)
{
case "+": result = Num1 + Num2; break;
case "-": result = Num1 - Num2; break;
case "*": result = Num1 * Num2; break;
case "/": result = Num1 / Num2; break;
default: result = 0; break;

}
txtResult.Text = result.ToString();
}

private void btnClear_Click(object sender, EventArgs e)
{
txtResult.Text = "";///////////////這是處理」清除鍵「的功能。。即:清除所有數字。。
Num1 = 0;
Num2 = 0;
op = "";

}

private void btnBackspace_Click(object sender, EventArgs e)
{
int len = txtResult.Text.Length;
if (len != 0)
txtResult.Text = txtResult.Text.Substring(0, len - 1);////這是處理「退格鍵」的問題。。即:除去最後一個數字。。。
}

private void button20_Click(object sender, EventArgs e)
{
if (txtResult.Text != "")
{
double temp = double.Parse(txtResult.Text);////這是處理「相反數」的問題。。即:先按個『9「鍵。再按此鍵變為」-9「
temp = temp * (-1);
txtResult.Text = temp.ToString();

}
}

private void button4_Click(object sender, EventArgs e)
{

if (txtResult.Text != "")
{
double temp = double.Parse(txtResult.Text);//這是」餘弦「問題。。。
temp = Math.Cos(temp);
txtResult.Text = temp.ToString();

}
}

private void button4_Click_1(object sender, EventArgs e)
{
if (txtResult.Text != "")
{
double temp = double.Parse(txtResult.Text);//////這是處理」正切「問題。。
temp = Math.Tan(temp);
txtResult.Text = temp.ToString();
}
}

}
}

熱點內容
緩存40集電視劇需要多少流量 發布:2025-07-05 05:56:44 瀏覽:60
iso怎麼解壓到u盤 發布:2025-07-05 05:49:02 瀏覽:889
php參數設置 發布:2025-07-05 05:49:00 瀏覽:993
javacharacter 發布:2025-07-05 05:38:36 瀏覽:734
伺服器pcid地址怎麼看 發布:2025-07-05 05:35:40 瀏覽:383
安卓系統賺錢靠什麼 發布:2025-07-05 05:28:06 瀏覽:158
編譯不出來的原因 發布:2025-07-05 05:14:00 瀏覽:68
絕地求生國際服如何選擇伺服器 發布:2025-07-05 05:08:56 瀏覽:65
雲伺服器壓力測試 發布:2025-07-05 05:00:28 瀏覽:373
成套設備易損配件清單怎麼配置 發布:2025-07-05 04:55:43 瀏覽:295