1

I've written a script:

^!c::
ClipSave := ClipboardAll
Send ^x
Run calc.exe
WinWaitActive Calculator
Send %clipboard%
Send Enter
Sleep 100
Send ^c
;WinClose
Send ^v
Clipboard := ClipSave

it's supposed to auto-calculate highlighted text, but it keeps doing weird calculations. For instance, '2+3' comes out as something like "reciproc(ln(tan(cube(2))))". Wat am i missing?

1
  • 1
    A variation of this script could send the text to Google to calculate Commented Sep 2, 2009 at 8:03

2 Answers 2

2

AutoHotkey sees the math symbols and turns them into AutoHotkey keystrokes. For example: + becomes Shift. So the calculator is taking 2 + 3 and interpreting it as the number 2 and Shift + 3.

Don't forget Return at the bottom of scripts, too. This might be triggering the extra junk as well.

I added some Sleeps as well, it was getting ahead of itself even with ClipWait.

Here is the script.

+^c::
ClipSaved := ClipboardAll
SendInput ^x
Run calc.exe
WinWaitActive Calculator
clipboard = %clipboard%
SendInput {Raw}%clipboard%
SendInput {Enter}
Sleep 100
SendInput ^c
Sleep 100
ClipWait, 2
WinClose
SendInput %clipboard%
Clipboard := ClipSaved
Return
1

To send the Enter key, you will want to enclose it in braces to specify it is a key.

Example:

Send {Enter}

Your call to WinClose is also commented out for some reason.

3
  • That helps, but now it just does cube(2)... Quite odd...
    – RCIX
    Commented Aug 29, 2009 at 5:54
  • You may also want to try using Send {Ctrl Down} {C Down} {Ctrl Up} {C Up} instead of ^c. I've had issues with it in the past.
    – user1931
    Commented Aug 29, 2009 at 6:12
  • That didn't really help...
    – RCIX
    Commented Sep 2, 2009 at 11:11

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .