自己编的计算器怎么才能像电脑里面自带的计算器那样显示啊
本帖最后由 2011风之叶 于 2012-2-15 22:43 编辑#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Global $ws, $ws1, $ws2 = 0, $ws2 = 1
Global $no = 0
#region ### START Koda GUI section ### Form=
$Form1 = GUICreate("计算器", 185, 257, Default, Default)
GUICtrlCreateGroup("", 8, 0, 169, 249)
GUICtrlCreateInput("", 16, 16, 153, 21)
$Button1 = GUICtrlCreateButton("1", 16, 168, 35, 33)
$Button2 = GUICtrlCreateButton("2", 56, 168, 35, 33)
$Button3 = GUICtrlCreateButton("3", 96, 168, 35, 33)
$Button4 = GUICtrlCreateButton("4", 16, 128, 35, 33)
$Button5 = GUICtrlCreateButton("5", 56, 128, 35, 33)
$Button6 = GUICtrlCreateButton("6", 96, 128, 35, 33)
$Button7 = GUICtrlCreateButton("7", 16, 88, 35, 33)
$Button8 = GUICtrlCreateButton("8", 56, 88, 35, 33)
$Button9 = GUICtrlCreateButton("9", 96, 88, 35, 33)
$Button10 = GUICtrlCreateButton("0", 16, 208, 75, 33)
$Button11 = GUICtrlCreateButton(".", 96, 208, 35, 33)
$Button12 = GUICtrlCreateButton("=", 136, 168, 35, 73)
$Button13 = GUICtrlCreateButton("+", 136, 88, 35, 73)
$Button14 = GUICtrlCreateButton("-", 136, 48, 35, 33)
$Button15 = GUICtrlCreateButton("×", 96, 48, 35, 33)
$Button16 = GUICtrlCreateButton("÷", 56, 48, 35, 33)
$Button17 = GUICtrlCreateButton("AC", 16, 48, 35, 33)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
#endregion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
$ws1 = 1
Case $Button2
$ws1 = 2
Case $Button3
$ws1 = 3
Case $Button4
$ws1 = 4
Case $Button5
$ws1 = 5
Case $Button6
$ws1 = 6
Case $Button7
$ws1 = 7
Case $Button8
$ws1 = 8
Case $Button9
$ws1 = 9
Case $Button10
$ws1 = 0
;~ Case $Button11
;~ $nMsg = "."
;~ $ws1=$nMsg
;~ MsgBox("", "", $ws1)
Case $Button12
If $no = 13 Then
$ws = $ws1 + $ws2
MsgBox(0x30, "计算器", $ws)
$no = 0
$ws1 = $ws
$ws2 = 0
ElseIf $no = 14 Then
$ws = $ws2 - $ws1
MsgBox(0x30, "计算器", $ws)
$no = 0
$ws1 = $ws
$ws2 = 0
ElseIf $no = 15 Then
$ws = $ws2 * $ws1
MsgBox(0x30, "计算器", $ws)
$no = 0
$ws1 = $ws
$ws2 = 1
ElseIf $no = 16 Then
$ws = $ws2 / $ws1
MsgBox(0x30, "计算器", $ws)
$no = 0
$ws1 = $ws
$ws2 = 1
EndIf
Case $Button13
If $no = 13 Then
$ws2 = $ws2 + $ws1
$no = 13
EndIf
If $no = 14 Then
$ws2 = $ws2 - $ws1
$no = 13
EndIf
If $no = 15 Then
$ws2 = $ws2 * $ws1
$no = 13
EndIf
If $no = 16 Then
$ws2 = $ws2 / $ws1
$no = 13
EndIf
If $no = 0 Then
$ws2 = $ws1
$no = 13
EndIf
Case $Button14
If $no = 14 Then
$ws2 = $ws2 - $ws1
$no = 14
EndIf
If $no = 13 Then
$ws2 = $ws2 + $ws1
$no = 14
EndIf
If $no = 15 Then
$ws2 = $ws2 * $ws1
$no = 14
EndIf
If $no = 16 Then
$ws2 = $ws2 / $ws1
$no = 14
EndIf
If $no = 0 Then
$ws2 = $ws1
$no = 14
EndIf
Case $Button15
If $no = 15 Then
$ws2 = $ws2 * $ws1
$no = 15
EndIf
If $no = 14 Then
$ws2 = $ws2 - $ws1
$no = 15
EndIf
If $no = 13 Then
$ws2 = $ws2 + $ws1
$no = 15
EndIf
If $no = 16 Then
$ws2 = $ws2 / $ws1
$no = 15
EndIf
If $no = 0 Then
$no = 15
$ws2 = $ws1
EndIf
Case $Button16
If $no = 16 Then
$ws2 = $ws2 / $ws1
$no = 16
EndIf
If $no = 15 Then
$ws2 = $ws2 * $ws1
$no = 16
EndIf
If $no = 14 Then
$ws2 = $ws2 - $ws1
$no = 16
EndIf
If $no = 13 Then
$ws2 = $ws2 + $ws1
$no = 16
EndIf
If $no = 0 Then
$ws2 =$ws1
$no = 16
EndIf
Case $Button17
$no = 0
$ws = 0
$ws1 = 0
$ws2 = 0
$ws2 = 1
$ws4 = 0
EndSwitch
WEnd
怎么才能像电脑里面自带的计算器那样显示啊 去看input控件ES_RIGHT样式 本帖最后由 netegg 于 2012-2-18 03:23 编辑
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GUIedit.au3>
Global $ws, $ws1, $ws2 = 0, $ws2 = 1
Global $no = 0
#region ### START Koda GUI section ### Form=
$Form1 = GUICreate("计算器", 185, 257, Default, Default)
GUICtrlCreateGroup("", 8, 0, 169, 249)
$Button = GUICtrlCreateInput("", 16, 16, 153, 21, $es_right)
$Button1 = GUICtrlCreateButton("1", 16, 168, 35, 33)
$Button2 = GUICtrlCreateButton("2", 56, 168, 35, 33)
$Button3 = GUICtrlCreateButton("3", 96, 168, 35, 33)
$Button4 = GUICtrlCreateButton("4", 16, 128, 35, 33)
$Button5 = GUICtrlCreateButton("5", 56, 128, 35, 33)
$Button6 = GUICtrlCreateButton("6", 96, 128, 35, 33)
$Button7 = GUICtrlCreateButton("7", 16, 88, 35, 33)
$Button8 = GUICtrlCreateButton("8", 56, 88, 35, 33)
$Button9 = GUICtrlCreateButton("9", 96, 88, 35, 33)
$Button10 = GUICtrlCreateButton("0", 16, 208, 75, 33)
$Button11 = GUICtrlCreateButton(".", 96, 208, 35, 33)
$Button12 = GUICtrlCreateButton("+", 136, 88, 35, 73)
$Button13 = GUICtrlCreateButton("-", 136, 48, 35, 33)
$Button14 = GUICtrlCreateButton("×", 96, 48, 35, 33)
$Button15 = GUICtrlCreateButton("÷", 56, 48, 35, 33)
$Button16 = GUICtrlCreateButton("=", 136, 168, 35, 73)
$Button17 = GUICtrlCreateButton("AC", 16, 48, 35, 33)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
#endregion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button16
GUICtrlSetData($Button, Execute(StringReplace(StringReplace(GUICtrlread($Button), "÷", '/'), "×", "*")))
Case $Button1, $Button2, $Button3, $Button4, $Button5, $Button6, $Button7, $Button8, $Button9, $Button10, _
$Button11, $Button12, $Button13, $Button14, $Button15 ;谢afan了
; Case $Button1 Or $Button2 Or $Button3 Or $Button4 Or $Button5 Or $Button6 Or $Button7 Or $Button8 Or $Button9 Or _
; $Button10 Or $Button11 Or $Button12 Or $Button13 Or $Button14 Or $Button15
$ws &= GUICtrlRead($nMsg)
GUICtrlSetData($Button, $ws)
EndSwitch
WEnd
不知道为什么我这运行不了,包括lz的那个代码,不过lz可以试试看 不知道为什么我这运行不了,包括lz的那个代码,不过lz可以试试看
netegg 发表于 2012-2-16 17:01 http://www.autoitx.com/images/common/back.gif
Case $Button1 Or $Button2 Or $Button3 Or ...不能这么用的,"or" 改成 "," 回复 4# afan
{:1_428:}
日,这都没注意 回复 5# netegg
别摸PP了,该打PP。 回复 6# afan
好疼的 回复 7# netegg Case $Button16
$v = Execute(StringReplace(StringReplace(GUICtrlRead($Button), "÷", '/'), "×", "*"))
GUICtrlSetData($Button, GUICtrlRead($Button) & '=' & $v)
Case $Button1 To $Button15
$ws &= GUICtrlRead($nMsg)
GUICtrlSetData($Button, $ws) 回复 3# netegg
你编的把or改成“,”就可以用啊。
我今天又把计算器改了一了下,小键盘的+ - * / 和Enter键没法用#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <WinAPIEx.au3>
Global Const $WM_HOTKEY = 0x0312
Global $ws, $ws1, $ws2 = 1, $ws3, $ws4, $ws5
Global $no = 0, $no1 = 0, $no2 = 0, $no3 = 0, $no4 = 0
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("计算器", 185, 257, Default, Default)
GUIRegisterMsg($WM_HOTKEY, 'WM_HOTKEY')
GUICtrlCreateGroup("", 8, 0, 169, 249)
GUICtrlCreateEdit("", 16, 16, 153, 21, BitOR($ES_RIGHT, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_READONLY, $ES_WANTRETURN))
GUICtrlSetData(-1, "0")
_WinAPI_RegisterHotKey($Form1, 0x0160, 0, 0x60);0
_WinAPI_RegisterHotKey($Form1, 0x0161, 0, 0x61);1
_WinAPI_RegisterHotKey($Form1, 0x0162, 0, 0x62);2
_WinAPI_RegisterHotKey($Form1, 0x0163, 0, 0x63);3
_WinAPI_RegisterHotKey($Form1, 0x0164, 0, 0x64);4
_WinAPI_RegisterHotKey($Form1, 0x0165, 0, 0x65);5
_WinAPI_RegisterHotKey($Form1, 0x0166, 0, 0x66);6
_WinAPI_RegisterHotKey($Form1, 0x0167, 0, 0x67);7
_WinAPI_RegisterHotKey($Form1, 0x0168, 0, 0x68);8
_WinAPI_RegisterHotKey($Form1, 0x0169, 0, 0x69);9
_WinAPI_RegisterHotKey($Form1, 0x016E, 0, 0x6E);.
_WinAPI_RegisterHotKey($Form1, 0x016C, 0, 0x6C);=
_WinAPI_RegisterHotKey($Form1, 0x016B, 0, 0x6B);+
_WinAPI_RegisterHotKey($Form1, 0x016D, 0, 0x6D);-
_WinAPI_RegisterHotKey($Form1, 0x016A, 0, 0x6A);*
_WinAPI_RegisterHotKey($Form1, 0x016F, 0, 0x6F);/
_WinAPI_RegisterHotKey($Form1, 0x0120, 0, 0x20);空格
$Button1 = GUICtrlCreateButton("1", 16, 168, 35, 33)
$Button2 = GUICtrlCreateButton("2", 56, 168, 35, 33)
$Button3 = GUICtrlCreateButton("3", 96, 168, 35, 33)
$Button4 = GUICtrlCreateButton("4", 16, 128, 35, 33)
$Button5 = GUICtrlCreateButton("5", 56, 128, 35, 33)
$Button6 = GUICtrlCreateButton("6", 96, 128, 35, 33)
$Button7 = GUICtrlCreateButton("7", 16, 88, 35, 33)
$Button8 = GUICtrlCreateButton("8", 56, 88, 35, 33)
$Button9 = GUICtrlCreateButton("9", 96, 88, 35, 33)
$Button10 = GUICtrlCreateButton("0", 16, 208, 75, 33)
$Button11 = GUICtrlCreateButton(".", 96, 208, 35, 33)
$Button12 = GUICtrlCreateButton("=", 136, 168, 35, 73)
$Button13 = GUICtrlCreateButton("+", 136, 88, 35, 73)
$Button14 = GUICtrlCreateButton("-", 136, 48, 35, 33)
$Button15 = GUICtrlCreateButton("×", 96, 48, 35, 33)
$Button16 = GUICtrlCreateButton("÷", 56, 48, 35, 33)
$Button17 = GUICtrlCreateButton("CE", 16, 48, 35, 33)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
$ws1 = 1
$no2 = 0
If $no1 = 0 Then
GUICtrlCreateEdit("", 16, 16, 153, 21, BitOR($ES_RIGHT, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_READONLY, $ES_WANTRETURN))
GUICtrlSetData(-1, $ws1)
$no1 = $ws1
Else
GUICtrlCreateEdit("", 16, 16, 153, 21, BitOR($ES_RIGHT, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_READONLY, $ES_WANTRETURN))
$no1 = Number($no1 & $ws1)
GUICtrlSetData(-1, $no1)
$ws1 = $no1
EndIf
Case $Button2
$ws1 = 2
$no2 = 0
If $no1 = 0 Then
GUICtrlCreateEdit("", 16, 16, 153, 21, BitOR($ES_RIGHT, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_READONLY, $ES_WANTRETURN))
GUICtrlSetData(-1, $ws1)
$no1 = $ws1
Else
GUICtrlCreateEdit("", 16, 16, 153, 21, BitOR($ES_RIGHT, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_READONLY, $ES_WANTRETURN))
$no1 = Number($no1 & $ws1)
GUICtrlSetData(-1, $no1)
$ws1 = $no1
EndIf
Case $Button3
$ws1 = 3
$no2 = 0
If $no1 = 0 Then
GUICtrlCreateEdit("", 16, 16, 153, 21, BitOR($ES_RIGHT, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_READONLY, $ES_WANTRETURN))
GUICtrlSetData(-1, $ws1)
$no1 = $ws1
Else
GUICtrlCreateEdit("", 16, 16, 153, 21, BitOR($ES_RIGHT, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_READONLY, $ES_WANTRETURN))
$no1 = Number($no1 & $ws1)
GUICtrlSetData(-1, $no1)
$ws1 = $no1
EndIf
Case $Button4
$ws1 = 4
$no2 = 0
If $no1 = 0 Then
GUICtrlCreateEdit("", 16, 16, 153, 21, BitOR($ES_RIGHT, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_READONLY, $ES_WANTRETURN))
GUICtrlSetData(-1, $ws1)
$no1 = $ws1
Else
GUICtrlCreateEdit("", 16, 16, 153, 21, BitOR($ES_RIGHT, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_READONLY, $ES_WANTRETURN))
$no1 = Number($no1 & $ws1)
GUICtrlSetData(-1, $no1)
$ws1 = $no1
EndIf
Case $Button5
$ws1 = 5
$no2 = 0
If $no1 = 0 Then
GUICtrlCreateEdit("", 16, 16, 153, 21, BitOR($ES_RIGHT, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_READONLY, $ES_WANTRETURN))
GUICtrlSetData(-1, $ws1)
$no1 = $ws1
Else
GUICtrlCreateEdit("", 16, 16, 153, 21, BitOR($ES_RIGHT, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_READONLY, $ES_WANTRETURN))
$no1 = Number($no1 & $ws1)
GUICtrlSetData(-1, $no1)
$ws1 = $no1
EndIf
Case $Button6
$ws1 = 6
$no2 = 0
If $no1 = 0 Then
GUICtrlCreateEdit("", 16, 16, 153, 21, BitOR($ES_RIGHT, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_READONLY, $ES_WANTRETURN))
GUICtrlSetData(-1, $ws1)
$no1 = $ws1
Else
GUICtrlCreateEdit("", 16, 16, 153, 21, BitOR($ES_RIGHT, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_READONLY, $ES_WANTRETURN))
$no1 = Number($no1 & $ws1)
GUICtrlSetData(-1, $no1)
$ws1 = $no1
EndIf
Case $Button7
$ws1 = 7
$no2 = 0
If $no1 = 0 Then
GUICtrlCreateEdit("", 16, 16, 153, 21, BitOR($ES_RIGHT, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_READONLY, $ES_WANTRETURN))
GUICtrlSetData(-1, $ws1)
$no1 = $ws1
Else
GUICtrlCreateEdit("", 16, 16, 153, 21, BitOR($ES_RIGHT, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_READONLY, $ES_WANTRETURN))
$no1 = Number($no1 & $ws1)
GUICtrlSetData(-1, $no1)
$ws1 = $no1
EndIf
Case $Button8
$ws1 = 8
$no2 = 0
If $no1 = 0 Then
GUICtrlCreateEdit("", 16, 16, 153, 21, BitOR($ES_RIGHT, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_READONLY, $ES_WANTRETURN))
GUICtrlSetData(-1, $ws1)
$no1 = $ws1
Else
GUICtrlCreateEdit("", 16, 16, 153, 21, BitOR($ES_RIGHT, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_READONLY, $ES_WANTRETURN))
$no1 = Number($no1 & $ws1)
GUICtrlSetData(-1, $no1)
$ws1 = $no1
EndIf
Case $Button9
$ws1 = 9
$no2 = 0
If $no1 = 0 Then
GUICtrlCreateEdit("", 16, 16, 153, 21, BitOR($ES_RIGHT, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_READONLY, $ES_WANTRETURN))
GUICtrlSetData(-1, $ws1)
$no1 = $ws1
Else
GUICtrlCreateEdit("", 16, 16, 153, 21, BitOR($ES_RIGHT, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_READONLY, $ES_WANTRETURN))
$no1 = Number($no1 & $ws1)
GUICtrlSetData(-1, $no1)
$ws1 = $no1
EndIf
Case $Button10
$ws1 = 0
$no2 = 0
If $no1 = 0 Then
GUICtrlCreateEdit("", 16, 16, 153, 21, BitOR($ES_RIGHT, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_READONLY, $ES_WANTRETURN))
GUICtrlSetData(-1, $ws1)
$no1 = $ws1
Else
GUICtrlCreateEdit("", 16, 16, 153, 21, BitOR($ES_RIGHT, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_READONLY, $ES_WANTRETURN))
$no1 = $no1 & $ws1
GUICtrlSetData(-1, $no1)
$ws1 = $no1
EndIf
Case $Button11
$ws1 = "."
$no2 = 0
If $no1 = 0 Then
GUICtrlCreateEdit("", 16, 16, 153, 21, BitOR($ES_RIGHT, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_READONLY, $ES_WANTRETURN))
GUICtrlSetData(-1, $ws1)
$no1 = $ws1
Else
GUICtrlCreateEdit("", 16, 16, 153, 21, BitOR($ES_RIGHT, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_READONLY, $ES_WANTRETURN))
$no1 = $no1 & $ws1
GUICtrlSetData(-1, $no1)
$ws1 = Number($no1)
EndIf
Case $Button12
$no1 = 0
While $no = 13
$ws = $ws2 + $ws1
GUICtrlCreateEdit("", 16, 16, 153, 21, BitOR($ES_RIGHT, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_READONLY, $ES_WANTRETURN))
GUICtrlSetData(-1, $ws)
$no = 0
$no1 = 0
$no2 = 0
$no3 = 1
$no4 = 1
$ws3 = $ws1
$ws4 = $ws
$ws1 = $ws
$ws2 = 0
WEnd
While $no = 14
$ws = $ws2 - $ws1
GUICtrlCreateEdit("", 16, 16, 153, 21, BitOR($ES_RIGHT, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_READONLY, $ES_WANTRETURN))
GUICtrlSetData(-1, $ws)
$no = 0
$no1 = 0
$no2 = 0
$no3 = 2
$no4 = 1
$ws4 = $ws
$ws3 = $ws1
$ws1 = $ws
$ws2 = 0
WEnd
While $no = 15
$ws = $ws2 * $ws1
GUICtrlCreateEdit("", 16, 16, 153, 21, BitOR($ES_RIGHT, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_READONLY, $ES_WANTRETURN))
GUICtrlSetData(-1, $ws)
$no = 0
$no1 = 0
$no2 = 0
$no3 = 3
$no4 = 1
$ws4 = $ws
$ws3 = $ws1
$ws1 = $ws
$ws2 = 1
WEnd
While $no = 16
$ws = $ws2 / $ws1
GUICtrlCreateEdit("", 16, 16, 153, 21, BitOR($ES_RIGHT, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_READONLY, $ES_WANTRETURN))
GUICtrlSetData(-1, $ws)
$no = 0
$no1 = 0
$no2 = 0
$no3 = 4
$no4 = 1
$ws4 = $ws
$ws3 = $ws1
$ws1 = $ws
$ws2 = 1
WEnd
Switch $no3
Case 1
$ws2 = $ws1
$ws1 = $ws3
$no = 13
Case 2
$ws2 = $ws1
$ws1 = $ws3
$no = 14
Case 3
$ws2 = $ws1
$ws1 = $ws3
$no = 15
Case 4
$ws2 = $ws1
$ws1 = $ws3
$no = 16
EndSwitch
Case $Button13
$no1 = 0
If $no = 0 Then
$ws2 = $ws1
$no = 13
ElseIf $no2 = 1 Then
$ws2 = $ws1
$no = 13
$no2 = 1
Else
Switch $no
Case 13
If $no4 = 1 Then
$ws2 = $ws4
$no = 13
$no2 = 1
Else
$ws2 = $ws2 + $ws1
GUICtrlCreateEdit("", 16, 16, 153, 21, BitOR($ES_RIGHT, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_READONLY, $ES_WANTRETURN))
GUICtrlSetData(-1, $ws2)
$no = 13
$no2 = 1
EndIf
Case 14
If $no4 = 1 Then
$ws2 = $ws4
$no = 13
$no2 = 1
Else
$ws2 = $ws2 - $ws1
GUICtrlCreateEdit("", 16, 16, 153, 21, BitOR($ES_RIGHT, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_READONLY, $ES_WANTRETURN))
GUICtrlSetData(-1, $ws2)
$no = 13
$no2 = 1
EndIf
Case 15
If $no4 = 1 Then
$ws2 = $ws4
$no = 13
$no2 = 1
Else
$ws2 = $ws2 * $ws1
GUICtrlCreateEdit("", 16, 16, 153, 21, BitOR($ES_RIGHT, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_READONLY, $ES_WANTRETURN))
GUICtrlSetData(-1, $ws2)
$no = 13
$no2 = 1
EndIf
Case 16
If $no4 = 1 Then
$ws2 = $ws4
$no = 13
$no2 = 1
Else
$ws2 = $ws2 / $ws1
GUICtrlCreateEdit("", 16, 16, 153, 21, BitOR($ES_RIGHT, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_READONLY, $ES_WANTRETURN))
GUICtrlSetData(-1, $ws2)
$no = 13
$no2 = 1
EndIf
EndSwitch
EndIf
Case $Button14
$no1 = 0
If $no = 0 Then
$ws2 = $ws1
$no = 14
$no2 = 1
ElseIf $no2 = 1 Then
$ws2 = $ws1
$no = 14
$no2 = 1
Else
Switch $no
Case 13
If $no4 = 1 Then
$ws2 = $ws4
$no = 14
$no2 = 1
Else
$ws2 = $ws2 + $ws1
GUICtrlCreateEdit("", 16, 16, 153, 21, BitOR($ES_RIGHT, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_READONLY, $ES_WANTRETURN))
GUICtrlSetData(-1, $ws2)
$no = 14
$no2 = 1
EndIf
Case 14
If $no4 = 1 Then
$ws2 = $ws4
$no = 14
$no2 = 1
Else
$ws2 = $ws2 - $ws1
GUICtrlCreateEdit("", 16, 16, 153, 21, BitOR($ES_RIGHT, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_READONLY, $ES_WANTRETURN))
GUICtrlSetData(-1, $ws2)
$no = 14
$no2 = 1
EndIf
Case 15
If $no4 = 1 Then
$ws2 = $ws4
$no = 14
$no2 = 1
Else
$ws2 = $ws2 * $ws1
GUICtrlCreateEdit("", 16, 16, 153, 21, BitOR($ES_RIGHT, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_READONLY, $ES_WANTRETURN))
GUICtrlSetData(-1, $ws2)
$no = 14
$no2 = 1
EndIf
Case 16
If $no4 = 1 Then
$ws2 = $ws4
$no = 14
$no2 = 1
Else
$ws2 = $ws2 / $ws1
GUICtrlCreateEdit("", 16, 16, 153, 21, BitOR($ES_RIGHT, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_READONLY, $ES_WANTRETURN))
GUICtrlSetData(-1, $ws2)
$no = 14
$no2 = 1
EndIf
EndSwitch
EndIf
Case $Button15
$no1 = 0
If $no = 0 Then
$ws2 = $ws1
$no = 15
$no2 = 1
ElseIf $no2 = 1 Then
$ws2 = $ws1
$no = 15
$no2 = 1
Else
Switch $no
Case 13
If $no4 = 1 Then
$ws2 = $ws4
$no = 15
$no2 = 1
Else
$ws2 = $ws2 + $ws1
GUICtrlCreateEdit("", 16, 16, 153, 21, BitOR($ES_RIGHT, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_READONLY, $ES_WANTRETURN))
GUICtrlSetData(-1, $ws2)
$no = 15
$no2 = 1
EndIf
Case 14
If $no4 = 1 Then
$ws2 = $ws4
$no = 15
$no2 = 1
Else
$ws2 = $ws2 - $ws1
GUICtrlCreateEdit("", 16, 16, 153, 21, BitOR($ES_RIGHT, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_READONLY, $ES_WANTRETURN))
GUICtrlSetData(-1, $ws2)
$no = 15
$no2 = 1
EndIf
Case 15
If $no4 = 1 Then
$ws2 = $ws4
$no = 15
$no2 = 1
Else
$ws2 = $ws2 * $ws1
GUICtrlCreateEdit("", 16, 16, 153, 21, BitOR($ES_RIGHT, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_READONLY, $ES_WANTRETURN))
GUICtrlSetData(-1, $ws2)
$no = 15
$no2 = 1
EndIf
Case 16
If $no4 = 1 Then
$ws2 = $ws4
$no = 15
$no2 = 1
Else
$ws2 = $ws2 / $ws1
GUICtrlCreateEdit("", 16, 16, 153, 21, BitOR($ES_RIGHT, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_READONLY, $ES_WANTRETURN))
GUICtrlSetData(-1, $ws2)
$no = 15
$no2 = 1
EndIf
EndSwitch
EndIf
Case $Button16
$no1 = 0
If $no = 0 Then
$ws2 = $ws1
$no = 16
$no2 = 1
ElseIf $no2 = 1 Then
$ws2 = $ws1
$no = 16
$no2 = 1
Else
Switch $no
Case 13
If $no4 = 1 Then
$ws2 = $ws4
$no = 16
$no2 = 1
Else
$ws2 = $ws2 + $ws1
GUICtrlCreateEdit("", 16, 16, 153, 21, BitOR($ES_RIGHT, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_READONLY, $ES_WANTRETURN))
GUICtrlSetData(-1, $ws2)
$no = 16
$no2 = 1
EndIf
Case 14
If $no4 = 1 Then
$ws2 = $ws4
$no = 16
$no2 = 1
Else
$ws2 = $ws2 - $ws1
GUICtrlCreateEdit("", 16, 16, 153, 21, BitOR($ES_RIGHT, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_READONLY, $ES_WANTRETURN))
GUICtrlSetData(-1, $ws2)
$no = 16
$no2 = 1
EndIf
Case 15
If $no4 = 1 Then
$ws2 = $ws4
$no = 16
$no2 = 1
Else
$ws2 = $ws2 * $ws1
GUICtrlCreateEdit("", 16, 16, 153, 21, BitOR($ES_RIGHT, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_READONLY, $ES_WANTRETURN))
GUICtrlSetData(-1, $ws2)
$no = 16
$no2 = 1
EndIf
Case 16
If $no4 = 1 Then
$ws2 = $ws4
$no = 16
$no2 = 1
Else
$ws2 = $ws2 / $ws1
GUICtrlCreateEdit("", 16, 16, 153, 21, BitOR($ES_RIGHT, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_READONLY, $ES_WANTRETURN))
GUICtrlSetData(-1, $ws2)
$no = 16
$no2 = 1
EndIf
EndSwitch
EndIf
Case $Button17
$no = 0
$no1 = 0
$no2 = 0
$no3 = 0
$no4 = 0
$ws = 0
$ws1 = ""
$ws2 = 1
$ws3 = 0
$ws4 = 0
$ws5 = 0
GUICtrlCreateEdit("", 16, 16, 153, 21, BitOR($ES_RIGHT, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_READONLY, $ES_WANTRETURN))
GUICtrlSetData(-1, 0)
EndSwitch
WEnd
Func WM_HOTKEY($Form1, $iMsg, $wParam, $lParam)
Switch _WinAPI_HiWord($lParam)
Case 0x60
$ws1 = $ws1 & '0'
GUICtrlCreateEdit("", 16, 16, 153, 21, BitOR($ES_RIGHT, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_READONLY, $ES_WANTRETURN))
GUICtrlSetData(-1, $ws1)
Case 0x61
$ws1 = Number($ws1 & '1')
GUICtrlCreateEdit("", 16, 16, 153, 21, BitOR($ES_RIGHT, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_READONLY, $ES_WANTRETURN))
GUICtrlSetData(-1, $ws1)
Case 0x62
$ws1 = Number($ws1 & '2')
GUICtrlCreateEdit("", 16, 16, 153, 21, BitOR($ES_RIGHT, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_READONLY, $ES_WANTRETURN))
GUICtrlSetData(-1, $ws1)
Case 0x63
$ws1 = Number($ws1 & '3')
GUICtrlCreateEdit("", 16, 16, 153, 21, BitOR($ES_RIGHT, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_READONLY, $ES_WANTRETURN))
GUICtrlSetData(-1, $ws1)
Case 0x64
$ws1 = Number($ws1 & '4')
GUICtrlCreateEdit("", 16, 16, 153, 21, BitOR($ES_RIGHT, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_READONLY, $ES_WANTRETURN))
GUICtrlSetData(-1, $ws1)
Case 0x65
$ws1 = Number($ws1 & '5')
GUICtrlCreateEdit("", 16, 16, 153, 21, BitOR($ES_RIGHT, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_READONLY, $ES_WANTRETURN))
GUICtrlSetData(-1, $ws1)
Case 0x66
$ws1 = Number($ws1 & '6')
GUICtrlCreateEdit("", 16, 16, 153, 21, BitOR($ES_RIGHT, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_READONLY, $ES_WANTRETURN))
GUICtrlSetData(-1, $ws1)
Case 0x67
$ws1 = Number($ws1 & '7')
GUICtrlCreateEdit("", 16, 16, 153, 21, BitOR($ES_RIGHT, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_READONLY, $ES_WANTRETURN))
GUICtrlSetData(-1, $ws1)
Case 0x68
$ws1 = Number($ws1 & '8')
GUICtrlCreateEdit("", 16, 16, 153, 21, BitOR($ES_RIGHT, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_READONLY, $ES_WANTRETURN))
GUICtrlSetData(-1, $ws1)
Case 0x69
$ws1 = Number($ws1 & '9')
GUICtrlCreateEdit("", 16, 16, 153, 21, BitOR($ES_RIGHT, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_READONLY, $ES_WANTRETURN))
GUICtrlSetData(-1, $ws1)
Case 0x6E
$ws1 = $ws1 & '.'
GUICtrlCreateEdit("", 16, 16, 153, 21, BitOR($ES_RIGHT, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_READONLY, $ES_WANTRETURN))
GUICtrlSetData(-1, $ws1)
Case 0x6B
$no1 = 0
If $no = 0 Then
$ws2 = $ws1
$no = 13
ElseIf $no2 = 1 Then
$ws2 = $ws1
$no = 13
$no2 = 1
Else
Switch $no
Case 13
If $no4 = 1 Then
$ws2 = $ws4
$no = 13
$no2 = 1
Else
$ws2 = $ws2 + $ws1
GUICtrlCreateEdit("", 16, 16, 153, 21, BitOR($ES_RIGHT, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_READONLY, $ES_WANTRETURN))
GUICtrlSetData(-1, $ws2)
$no = 13
$no2 = 1
EndIf
Case 14
If $no4 = 1 Then
$ws2 = $ws4
$no = 13
$no2 = 1
Else
$ws2 = $ws2 - $ws1
GUICtrlCreateEdit("", 16, 16, 153, 21, BitOR($ES_RIGHT, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_READONLY, $ES_WANTRETURN))
GUICtrlSetData(-1, $ws2)
$no = 13
$no2 = 1
EndIf
Case 15
If $no4 = 1 Then
$ws2 = $ws4
$no = 13
$no2 = 1
Else
$ws2 = $ws2 * $ws1
GUICtrlCreateEdit("", 16, 16, 153, 21, BitOR($ES_RIGHT, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_READONLY, $ES_WANTRETURN))
GUICtrlSetData(-1, $ws2)
$no = 13
$no2 = 1
EndIf
Case 16
If $no4 = 1 Then
$ws2 = $ws4
$no = 13
$no2 = 1
Else
$ws2 = $ws2 / $ws1
GUICtrlCreateEdit("", 16, 16, 153, 21, BitOR($ES_RIGHT, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_READONLY, $ES_WANTRETURN))
GUICtrlSetData(-1, $ws2)
$no = 13
$no2 = 1
EndIf
EndSwitch
EndIf
Case 0x6D
$no1 = 0
If $no = 0 Then
$ws2 = $ws1
$no = 14
$no2 = 1
ElseIf $no2 = 1 Then
$ws2 = $ws1
$no = 14
$no2 = 1
Else
Switch $no
Case 13
If $no4 = 1 Then
$ws2 = $ws4
$no = 14
$no2 = 1
Else
$ws2 = $ws2 + $ws1
GUICtrlCreateEdit("", 16, 16, 153, 21, BitOR($ES_RIGHT, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_READONLY, $ES_WANTRETURN))
GUICtrlSetData(-1, $ws2)
$no = 14
$no2 = 1
EndIf
Case 14
If $no4 = 1 Then
$ws2 = $ws4
$no = 14
$no2 = 1
Else
$ws2 = $ws2 - $ws1
GUICtrlCreateEdit("", 16, 16, 153, 21, BitOR($ES_RIGHT, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_READONLY, $ES_WANTRETURN))
GUICtrlSetData(-1, $ws2)
$no = 14
$no2 = 1
EndIf
Case 15
If $no4 = 1 Then
$ws2 = $ws4
$no = 14
$no2 = 1
Else
$ws2 = $ws2 * $ws1
GUICtrlCreateEdit("", 16, 16, 153, 21, BitOR($ES_RIGHT, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_READONLY, $ES_WANTRETURN))
GUICtrlSetData(-1, $ws2)
$no = 14
$no2 = 1
EndIf
Case 16
If $no4 = 1 Then
$ws2 = $ws4
$no = 14
$no2 = 1
Else
$ws2 = $ws2 / $ws1
GUICtrlCreateEdit("", 16, 16, 153, 21, BitOR($ES_RIGHT, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_READONLY, $ES_WANTRETURN))
GUICtrlSetData(-1, $ws2)
$no = 14
$no2 = 1
EndIf
EndSwitch
EndIf
Case 0x6A
$no1 = 0
If $no = 0 Then
$ws2 = $ws1
$no = 15
$no2 = 1
ElseIf $no2 = 1 Then
$ws2 = $ws1
$no = 15
$no2 = 1
Else
Switch $no
Case 13
If $no4 = 1 Then
$ws2 = $ws4
$no = 15
$no2 = 1
Else
$ws2 = $ws2 + $ws1
GUICtrlCreateEdit("", 16, 16, 153, 21, BitOR($ES_RIGHT, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_READONLY, $ES_WANTRETURN))
GUICtrlSetData(-1, $ws2)
$no = 15
$no2 = 1
EndIf
Case 14
If $no4 = 1 Then
$ws2 = $ws4
$no = 15
$no2 = 1
Else
$ws2 = $ws2 - $ws1
GUICtrlCreateEdit("", 16, 16, 153, 21, BitOR($ES_RIGHT, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_READONLY, $ES_WANTRETURN))
GUICtrlSetData(-1, $ws2)
$no = 15
$no2 = 1
EndIf
Case 15
If $no4 = 1 Then
$ws2 = $ws4
$no = 15
$no2 = 1
Else
$ws2 = $ws2 * $ws1
GUICtrlCreateEdit("", 16, 16, 153, 21, BitOR($ES_RIGHT, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_READONLY, $ES_WANTRETURN))
GUICtrlSetData(-1, $ws2)
$no = 15
$no2 = 1
EndIf
Case 16
If $no4 = 1 Then
$ws2 = $ws4
$no = 15
$no2 = 1
Else
$ws2 = $ws2 / $ws1
GUICtrlCreateEdit("", 16, 16, 153, 21, BitOR($ES_RIGHT, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_READONLY, $ES_WANTRETURN))
GUICtrlSetData(-1, $ws2)
$no = 15
$no2 = 1
EndIf
EndSwitch
EndIf
Case 0x6F
$no1 = 0
If $no = 0 Then
$ws2 = $ws1
$no = 16
$no2 = 1
ElseIf $no2 = 1 Then
$ws2 = $ws1
$no = 16
$no2 = 1
Else
Switch $no
Case 13
If $no4 = 1 Then
$ws2 = $ws4
$no = 16
$no2 = 1
Else
$ws2 = $ws2 + $ws1
GUICtrlCreateEdit("", 16, 16, 153, 21, BitOR($ES_RIGHT, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_READONLY, $ES_WANTRETURN))
GUICtrlSetData(-1, $ws2)
$no = 16
$no2 = 1
EndIf
Case 14
If $no4 = 1 Then
$ws2 = $ws4
$no = 16
$no2 = 1
Else
$ws2 = $ws2 - $ws1
GUICtrlCreateEdit("", 16, 16, 153, 21, BitOR($ES_RIGHT, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_READONLY, $ES_WANTRETURN))
GUICtrlSetData(-1, $ws2)
$no = 16
$no2 = 1
EndIf
Case 15
If $no4 = 1 Then
$ws2 = $ws4
$no = 16
$no2 = 1
Else
$ws2 = $ws2 * $ws1
GUICtrlCreateEdit("", 16, 16, 153, 21, BitOR($ES_RIGHT, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_READONLY, $ES_WANTRETURN))
GUICtrlSetData(-1, $ws2)
$no = 16
$no2 = 1
EndIf
Case 16
If $no4 = 1 Then
$ws2 = $ws4
$no = 16
$no2 = 1
Else
$ws2 = $ws2 / $ws1
GUICtrlCreateEdit("", 16, 16, 153, 21, BitOR($ES_RIGHT, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_READONLY, $ES_WANTRETURN))
GUICtrlSetData(-1, $ws2)
$no = 16
$no2 = 1
EndIf
EndSwitch
EndIf
Case 0x6C
$no1 = 0
While $no = 13
$ws = $ws2 + $ws1
GUICtrlCreateEdit("", 16, 16, 153, 21, BitOR($ES_RIGHT, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_READONLY, $ES_WANTRETURN))
GUICtrlSetData(-1, $ws)
$no = 0
$no1 = 0
$no2 = 0
$no3 = 1
$no4 = 1
$ws3 = $ws1
$ws4 = $ws
$ws1 = $ws
$ws2 = 0
WEnd
Case 0x20
$no = 0
$no1 = 0
$no2 = 0
$no3 = 0
$no4 = 0
$ws = 0
$ws1 = ""
$ws2 = 1
$ws3 = 0
$ws4 = 0
$ws5 = 0
GUICtrlCreateEdit("", 16, 16, 153, 21, BitOR($ES_RIGHT, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_READONLY, $ES_WANTRETURN))
GUICtrlSetData(-1, 0)
EndSwitch
EndFunc ;==>WM_HOTKEY
能不能帮我精减下,看的我头都大了 本帖最后由 netegg 于 2012-2-16 17:45 编辑
回复 8# afan
我记得case .... to好像可以,不过可能有个问题,就是如果=不是最后一个创建的就很麻烦,尽管用排除可以解决,反正按键不很多,这样就是累点,无所谓了
还有个问题,lz的意思不知道是要不要等号,我也没处理,这些很基本的东西,还是看帮助解决吧 回复 10# netegg
抬头,楼上来了劳力士… 本帖最后由 netegg 于 2012-2-16 17:57 编辑
这是要干什么,键盘设置用的着这么麻烦吗,做个小键盘的虚拟按键表,然后用虚拟代码转成10进制,和上面的处理方式一样
每个数字下面的while....wend是干什么的
另外就算lz想这样写, 既然每个条件下的操作都一样,做个子函数调用好了,这么麻烦干什么 回复 9# 2011风之叶
干嘛用这么多 GUICtrlCreateEdit ? 73个… 回复 9# 2011风之叶
看看 GUISetAccelerators() 函数吧,精简由此开始。 本帖最后由 netegg 于 2012-2-16 19:02 编辑
Local $AccelKeys = [["{NUMPAD1}", $Button1],["{NUMPAD2}", $Button2].....["{NUMPADENTER}", $Button17]]
GUISetAccelerators($AccelKeys, $GUI)
页:
[1]
2