Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|improve this question
1  
A variation of this script could send the text to Google to calculate –  Matthew Lock Sep 2 '09 at 8:03

2 Answers 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
share|improve this answer

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.

share|improve this answer
    
That helps, but now it just does cube(2)... Quite odd... –  RCIX Aug 29 '09 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. –  John T Aug 29 '09 at 6:12
    
That didn't really help... –  RCIX Sep 2 '09 at 11:11

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.