首页 > 解决方案 > 如何在 AHK 中将字符串转换为整数

问题描述

我在下面有这段代码,我想将像“0,0”这样的字符串转换为整数并将两个变量相加,并将其放在一个新变量上。我在互联网上寻找解决方案,但没有成功。

代码:

    MouseMove, 238,282
    MouseClickDrag, Left, 238,282, 238,282
    Sleep, 200
    Send, {CTRLDOWN}c{CTRLUP}
    CLIPWAIT, 0.5
    SaldoContabil = %ClipBoard% ; here is getting 0,0
    Sleep, 400

    MouseMove, 602,283
    MouseClickDrag, Left, 602,283, 602,283
    Sleep, 500
    Send, {CTRLDOWN}c{CTRLUP}
    CLIPWAIT, 0.5
    ArredAcumulado = %ClipBoard% ; here is getting 0,0
    Sleep, 400


    baixa = %ArredAcumulado% - %SaldoContabil%

标签: autohotkey

解决方案


在最终计算之前添加以下行。
StrReplace只是用你得到,. so替换,不需要进一步的转换。0,00.0

SaldoContabil := StrReplace(SaldoContabil,",",".")
ArredAcumulado := StrReplace(ArredAcumulado ,",",".")

推荐阅读