Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一种情况,程序等待用户按下接受,然后开始执行一些操作。如果某个条件为真,我想得到所有的动作。我可以输入:
if condition = true then ...
但是“then”的代码太多了。如果我能写这样的东西会容易得多:
if true then press accept
所以它会像用户按下它一样对待。到目前为止我找不到任何方法。有没有办法做到这一点?
您需要解释为什么按照您的建议做比写更好:
IF condition != TRUE THEN …input operation waiting for ACCEPT… END IF CALL function_to_do_actions(…)
(您甚至不必调用函数;您可以简单地在测试之后编写操作。)
我不认为有一个记录在案的方式来做你所要求的——假装按键。