select...Case...EndSelect 我的代码有问题
select...Case...EndSelect having problems with my code
我正在尝试为一个简单的数学问题构建一个自动答案,其中问题中的总变量数取决于问号的位置,这里有几个例子:
What is 56 x 3 ?
What is 7 x 3 ?
What is 232 x 634 ?
我已经创建了一个代码,但我无法让它工作,这是我的代码
#include <AutoItConstants.au3>
HotKeySet("{F4}", "ExitProg")
Func ExitProg()
Exit 0
EndFunc
MouseClick($MOUSE_CLICK_LEFT, 417, 659, 2, 1)
Send("^c")
Func valData()
$Chek = "What "
If ClipGet() == $Chek Then
Check()
Else
Do
MouseClick($MOUSE_CLICK_LEFT, 417, 659, 2, 3)
Send("^c")
Sleep(500)
Until ClipGet() == $Chek
EndIf
EndFunc
Func Check()
$Chek2 = "?"
Select
Case c1() == $Chek2
;two
cc1()
Case c2() == $Chek2
;three
cc2()
Case c3() == $Chek2
;four
cc3()
Case c4() == $Chek2
;five
cc4()
Case c5() == $Chek2
;six
cc5()
Case c6() == $Chek2
;seven
cc6()
Case c7() == $Chek2
;eight
cc7()
Case Else
Exit
EndSelect
EndFunc
Func c1()
MouseClick($MOUSE_CLICK_LEFT, 485, 643, 2, 1)
Send("^c")
EndFunc
Func c2()
MouseClick($MOUSE_CLICK_LEFT, 493, 644, 2, 1)
Send("^c")
EndFunc
Func c3()
MouseClick($MOUSE_CLICK_LEFT, 498, 645, 2, 1)
Send("^c")
EndFunc
Func c4()
MouseClick($MOUSE_CLICK_LEFT, 508, 647, 2, 1)
Send("^c")
EndFunc
Func c5()
MouseClick($MOUSE_CLICK_LEFT, 514, 645, 2, 1)
Send("^c")
EndFunc
Func c6()
MouseClick($MOUSE_CLICK_LEFT, 523, 645, 2, 1)
Send("^c")
EndFunc
Func c7()
MouseClick($MOUSE_CLICK_LEFT, 530, 645, 2, 1)
Send("^c")
EndFunc
Func cc1()
MouseClick($MOUSE_CLICK_LEFT, 453, 645, 2, 1)
Send("^c")
Sleep(500)
MouseClick($MOUSE_CLICK_LEFT, 1347, 197, 1, 1)
Send("^v")
Sleep(500)
MouseClick($MOUSE_CLICK_LEFT, 474, 645, 2, 1)
Send("^c")
Sleep(500)
MouseClick($MOUSE_CLICK_LEFT, 1347, 197, 1, 1)
Send("*")
Send("^v")
Send("{NUMPADENTER}")
EndFunc
Func cc2()
MouseClick($MOUSE_CLICK_LEFT, 453, 645, 2, 1)
Send("^c")
Sleep(500)
MouseClick($MOUSE_CLICK_LEFT, 1347, 197, 1, 1)
Send("^v")
SLeep(500)
MouseClick($MOUSE_CLICK_LEFT, 482, 645, 2, 1)
Send("^c")
Sleep(500)
MouseClick($MOUSE_CLICK_LEFT, 1347, 197, 1, 1)
Send("*")
Send("^v")
Send("{NUMPADENTER}")
EndFunc
Func cc3()
MouseClick($MOUSE_CLICK_LEFT, 453, 645, 2, 1)
Send("^c")
Sleep(500)
MouseClick($MOUSE_CLICK_LEFT, 1347, 197, 1, 1)
Send("^v")
Sleep(500)
MouseClick($MOUSE_CLICK_LEFT, 487, 645, 2, 1)
Send("^c")
Sleep(500)
MouseClick($MOUSE_CLICK_LEFT, 1347, 197, 1, 1)
Send("*")
Send("^v")
Send("{NUMPADENTER}")
EndFunc
Func cc4()
MouseClick($MOUSE_CLICK_LEFT, 453, 645, 2, 1)
Send("^c")
Sleep(500)
MouseClick($MOUSE_CLICK_LEFT, 1347, 197, 1, 1)
Send("^v")
Sleep(500)
MouseClick($MOUSE_CLICK_LEFT, 495, 645, 2, 1)
Send("^c")
Sleep(500)
MouseClick($MOUSE_CLICK_LEFT, 1347, 197, 1, 1)
Send("*")
Send("^v")
Send("{NUMPADENTER}")
EndFunc
Func cc5()
MouseClick($MOUSE_CLICK_LEFT, 453, 645, 2, 1)
Send("^c")
Sleep(500)
MouseClick($MOUSE_CLICK_LEFT, 1347, 197, 1, 1)
Send("^v")
Sleep(500)
MouseClick($MOUSE_CLICK_LEFT, 495, 645, 2, 1)
Send("^c")
Sleep(500)
MouseClick($MOUSE_CLICK_LEFT, 1347, 197, 1, 1)
Send("*")
Send("^v")
Send("{NUMPADENTER}")
EndFunc
Func cc6()
MouseClick($MOUSE_CLICK_LEFT, 453, 645, 2, 1)
Send("^c")
Sleep(500)
MouseClick($MOUSE_CLICK_LEFT, 1347, 197, 1, 1)
Send("^v")
Sleep(500)
MouseClick($MOUSE_CLICK_LEFT, 509, 645, 2, 1)
Send("^c")
Sleep(500)
MouseClick($MOUSE_CLICK_LEFT, 1347, 197, 1, 1)
Send("*")
Send("^v")
Send("{NUMPADENTER}")
EndFunc
Func cc7()
MouseClick($MOUSE_CLICK_LEFT, 453, 645, 2, 1)
Send("^c")
Sleep(500)
MouseClick($MOUSE_CLICK_LEFT, 1347, 197, 1, 1)
Send("^v")
Sleep(500)
MouseClick($MOUSE_CLICK_LEFT, 509, 645, 2, 1)
Send("^c")
Sleep(500)
MouseClick($MOUSE_CLICK_LEFT, 1347, 197, 1, 1)
Send("*")
Send("^v")
Send("{NUMPADENTER}")
EndFunc
valData()
MouseClick($MOUSE_CLICK_LEFT, 1349, 196, 1, 1) ;clicking the answer in calc
Send("^c")
Send("{DEL}")
MouseClick($MOUSE_CLICK_LEFT, 499, 706, 1, 1)
Send("^v")
Exit
请帮帮我!这个的输出只是搜索问号,然后什么都不做。
这与 user4157124
已经给出的答案基本相同。我只是把它分解成一行(牺牲错误处理;如果问题不符合给定的格式,$x
无论如何都会是空的)。
ClipPut("What is 14 x 36 ?")
$x = Execute(StringRegExpReplace(ClipGet(), '^What is (\d*) x (\d*) \?$', "*"))
ConsoleWrite($x & @CRLF)
REGEX 模式 [^\d]*(\d+)[^\d]+(\d+).*
也有效(如果问题中或周围有杂散空间则更可靠)
(GUICtrlRead()
有更优雅的出题方式,但实现取决于源程序的具体构建方式)
编辑(仅用于故障排除):
由于我看不到你的屏幕,请运行以下内容进行故障排除:
MouseClick("Primary", 479, 802, 3, 10) ; slowed down to verify that the cursor goes to the right position
Send("^c")
$x = ClipGet()
ConsoleWrite('Whole question: "' & $x & '"' & @CRLF)
$x = StringRegExpReplace(ClipGet(), 'What is (\d*) x (\d*) \?$', "*")
ConsoleWrite('Math part: "' & $x & '"' & @CRLF)
$x = Execute($x)
ConsoleWrite('Result: "' & $x & '"' & @CRLF)
; MouseClick("Primary", 480, 844, 1, 1)
; Send($x)
请报告控制台的确切输出,这样我就可以看到哪里开始出错了。
我正在尝试为一个简单的数学问题构建一个自动答案,其中问题中的总变量数取决于问号的位置,这里有几个例子:
What is 56 x 3 ?
What is 7 x 3 ?
What is 232 x 634 ?
我已经创建了一个代码,但我无法让它工作,这是我的代码
#include <AutoItConstants.au3>
HotKeySet("{F4}", "ExitProg")
Func ExitProg()
Exit 0
EndFunc
MouseClick($MOUSE_CLICK_LEFT, 417, 659, 2, 1)
Send("^c")
Func valData()
$Chek = "What "
If ClipGet() == $Chek Then
Check()
Else
Do
MouseClick($MOUSE_CLICK_LEFT, 417, 659, 2, 3)
Send("^c")
Sleep(500)
Until ClipGet() == $Chek
EndIf
EndFunc
Func Check()
$Chek2 = "?"
Select
Case c1() == $Chek2
;two
cc1()
Case c2() == $Chek2
;three
cc2()
Case c3() == $Chek2
;four
cc3()
Case c4() == $Chek2
;five
cc4()
Case c5() == $Chek2
;six
cc5()
Case c6() == $Chek2
;seven
cc6()
Case c7() == $Chek2
;eight
cc7()
Case Else
Exit
EndSelect
EndFunc
Func c1()
MouseClick($MOUSE_CLICK_LEFT, 485, 643, 2, 1)
Send("^c")
EndFunc
Func c2()
MouseClick($MOUSE_CLICK_LEFT, 493, 644, 2, 1)
Send("^c")
EndFunc
Func c3()
MouseClick($MOUSE_CLICK_LEFT, 498, 645, 2, 1)
Send("^c")
EndFunc
Func c4()
MouseClick($MOUSE_CLICK_LEFT, 508, 647, 2, 1)
Send("^c")
EndFunc
Func c5()
MouseClick($MOUSE_CLICK_LEFT, 514, 645, 2, 1)
Send("^c")
EndFunc
Func c6()
MouseClick($MOUSE_CLICK_LEFT, 523, 645, 2, 1)
Send("^c")
EndFunc
Func c7()
MouseClick($MOUSE_CLICK_LEFT, 530, 645, 2, 1)
Send("^c")
EndFunc
Func cc1()
MouseClick($MOUSE_CLICK_LEFT, 453, 645, 2, 1)
Send("^c")
Sleep(500)
MouseClick($MOUSE_CLICK_LEFT, 1347, 197, 1, 1)
Send("^v")
Sleep(500)
MouseClick($MOUSE_CLICK_LEFT, 474, 645, 2, 1)
Send("^c")
Sleep(500)
MouseClick($MOUSE_CLICK_LEFT, 1347, 197, 1, 1)
Send("*")
Send("^v")
Send("{NUMPADENTER}")
EndFunc
Func cc2()
MouseClick($MOUSE_CLICK_LEFT, 453, 645, 2, 1)
Send("^c")
Sleep(500)
MouseClick($MOUSE_CLICK_LEFT, 1347, 197, 1, 1)
Send("^v")
SLeep(500)
MouseClick($MOUSE_CLICK_LEFT, 482, 645, 2, 1)
Send("^c")
Sleep(500)
MouseClick($MOUSE_CLICK_LEFT, 1347, 197, 1, 1)
Send("*")
Send("^v")
Send("{NUMPADENTER}")
EndFunc
Func cc3()
MouseClick($MOUSE_CLICK_LEFT, 453, 645, 2, 1)
Send("^c")
Sleep(500)
MouseClick($MOUSE_CLICK_LEFT, 1347, 197, 1, 1)
Send("^v")
Sleep(500)
MouseClick($MOUSE_CLICK_LEFT, 487, 645, 2, 1)
Send("^c")
Sleep(500)
MouseClick($MOUSE_CLICK_LEFT, 1347, 197, 1, 1)
Send("*")
Send("^v")
Send("{NUMPADENTER}")
EndFunc
Func cc4()
MouseClick($MOUSE_CLICK_LEFT, 453, 645, 2, 1)
Send("^c")
Sleep(500)
MouseClick($MOUSE_CLICK_LEFT, 1347, 197, 1, 1)
Send("^v")
Sleep(500)
MouseClick($MOUSE_CLICK_LEFT, 495, 645, 2, 1)
Send("^c")
Sleep(500)
MouseClick($MOUSE_CLICK_LEFT, 1347, 197, 1, 1)
Send("*")
Send("^v")
Send("{NUMPADENTER}")
EndFunc
Func cc5()
MouseClick($MOUSE_CLICK_LEFT, 453, 645, 2, 1)
Send("^c")
Sleep(500)
MouseClick($MOUSE_CLICK_LEFT, 1347, 197, 1, 1)
Send("^v")
Sleep(500)
MouseClick($MOUSE_CLICK_LEFT, 495, 645, 2, 1)
Send("^c")
Sleep(500)
MouseClick($MOUSE_CLICK_LEFT, 1347, 197, 1, 1)
Send("*")
Send("^v")
Send("{NUMPADENTER}")
EndFunc
Func cc6()
MouseClick($MOUSE_CLICK_LEFT, 453, 645, 2, 1)
Send("^c")
Sleep(500)
MouseClick($MOUSE_CLICK_LEFT, 1347, 197, 1, 1)
Send("^v")
Sleep(500)
MouseClick($MOUSE_CLICK_LEFT, 509, 645, 2, 1)
Send("^c")
Sleep(500)
MouseClick($MOUSE_CLICK_LEFT, 1347, 197, 1, 1)
Send("*")
Send("^v")
Send("{NUMPADENTER}")
EndFunc
Func cc7()
MouseClick($MOUSE_CLICK_LEFT, 453, 645, 2, 1)
Send("^c")
Sleep(500)
MouseClick($MOUSE_CLICK_LEFT, 1347, 197, 1, 1)
Send("^v")
Sleep(500)
MouseClick($MOUSE_CLICK_LEFT, 509, 645, 2, 1)
Send("^c")
Sleep(500)
MouseClick($MOUSE_CLICK_LEFT, 1347, 197, 1, 1)
Send("*")
Send("^v")
Send("{NUMPADENTER}")
EndFunc
valData()
MouseClick($MOUSE_CLICK_LEFT, 1349, 196, 1, 1) ;clicking the answer in calc
Send("^c")
Send("{DEL}")
MouseClick($MOUSE_CLICK_LEFT, 499, 706, 1, 1)
Send("^v")
Exit
请帮帮我!这个的输出只是搜索问号,然后什么都不做。
这与 user4157124
已经给出的答案基本相同。我只是把它分解成一行(牺牲错误处理;如果问题不符合给定的格式,$x
无论如何都会是空的)。
ClipPut("What is 14 x 36 ?")
$x = Execute(StringRegExpReplace(ClipGet(), '^What is (\d*) x (\d*) \?$', "*"))
ConsoleWrite($x & @CRLF)
REGEX 模式 [^\d]*(\d+)[^\d]+(\d+).*
也有效(如果问题中或周围有杂散空间则更可靠)
(GUICtrlRead()
有更优雅的出题方式,但实现取决于源程序的具体构建方式)
编辑(仅用于故障排除):
由于我看不到你的屏幕,请运行以下内容进行故障排除:
MouseClick("Primary", 479, 802, 3, 10) ; slowed down to verify that the cursor goes to the right position
Send("^c")
$x = ClipGet()
ConsoleWrite('Whole question: "' & $x & '"' & @CRLF)
$x = StringRegExpReplace(ClipGet(), 'What is (\d*) x (\d*) \?$', "*")
ConsoleWrite('Math part: "' & $x & '"' & @CRLF)
$x = Execute($x)
ConsoleWrite('Result: "' & $x & '"' & @CRLF)
; MouseClick("Primary", 480, 844, 1, 1)
; Send($x)
请报告控制台的确切输出,这样我就可以看到哪里开始出错了。