脚本制作计算器
⑴ 如何制作flash计算器
使用if语句来解决吧if语句-计算器
(a1/a2为输入文本,a3为动态文本)
//在按钮上添加此脚本,直接运算结果
on (release) {
_root.a3 = Number(_root.a1)+Number(_root.a2);
}
(另一种计算器的做法)
//加上所写脚本,其它运算方式相似
on(release){
k=1;
}
//计算按钮上所需脚本
on(release){
_root.COLOR: lime; FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">您的输入有误!";
if(k==1){
_root.c=Number(_root.a)+Number(_root.b);
}
if(k==2){
_root.c=Number(_root.a)-Number(_root.b);
}
if(k==3){
_root.c=Number(_root.a)*Number(_root.b);
}
if(k==4){
_root.c=Number(_root.a)/Number(_root.b);
}
}
//a、b为两个输入文本,c为显示结果的动态文本
⑵ 用python操作Windows的计算器。
pyhook可以抓到键。
不过这里只需要消息就可以了,win32api中的windows的message
使用vc中的消息 工具,抓键盘消息。然后再把这个消息包装一下用pywin32中的API发送过去。
我以前用pyhook加pywin32, 控制过一个游戏,做外挂。
也用pywin32的com接口控制过excel
⑶ 利用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>