Jump to content
Sign in to follow this  
poisonkiller

Calculating

Recommended Posts

poisonkiller

Im making script, what calculates numbers in edit box.You have to check "+" or "-" or "/" or "*".Script open calculator and calculates there sum. My code:

#include <File.au3>
#include <GUIConstants.au3>
Dim $read[100]
GUICreate("Kalkulaator", 250, 500)
$num = GUICtrlCreateEdit("", 10, 10, 190, 460)
$calc = GUICtrlCreateButton("Calculate...", 20, 480, 70, 20)
$delnum = GUICtrlCreateButton("Delete num.", 100, 480, 70, 20)
$plus = GUICtrlCreateRadio("+", 200, 10, 50, 20)
$minus = GUICtrlCreateRadio("-", 200, 30, 50, 20)
$korda = GUICtrlCreateRadio("*", 200, 50, 50, 20)
$jaga = GUICtrlCreateRadio("/", 200, 70, 50, 20)
GUISetState()
Do
    $msg = GUIGetMsg()
Select
Case $msg = $calc
_FileCreate("data.txt")
FileWrite("data.txt", GUICtrlRead($num))
Run("calc.exe") 
WinWaitActive("Calculator")
$read[1] = FileReadLine("data.txt", 1)  
Send($read[1]) 
$read[2] = FileReadLine("data.txt", 2) 
Send($read[2]) 
$read[3] = FileReadLine("data.txt", 3) 
Send($read[3]) 

EndSelect

Until $msg = $GUI_EVENT_CLOSE

And like usually, sorry about my bad english. ;)

Share this post


Link to post
Share on other sites
Valuater

played with it a lttle

#include <File.au3>
#include <GUIConstants.au3>
Dim $read[100]
GUICreate("Kalkulaator", 250, 500)
$num = GUICtrlCreateEdit("", 10, 10, 190, 460)
$calc = GUICtrlCreateButton("Calculate...", 20, 480, 70, 20)
$delnum = GUICtrlCreateButton("Delete num.", 100, 480, 70, 20)
$plus = GUICtrlCreateRadio("+", 200, 10, 50, 20)
$minus = GUICtrlCreateRadio("-", 200, 30, 50, 20)
$korda = GUICtrlCreateRadio("*", 200, 50, 50, 20)
$jaga = GUICtrlCreateRadio("/", 200, 70, 50, 20)
GUISetState()
Do
$msg = GUIGetMsg()
Select
Case $msg = $calc
_FileCreate("data.txt")
FileWrite("data.txt", GUICtrlRead($num))
If Not WinExists("Calculator") Then
    Run("calc.exe") 
    WinWaitActive("Calculator")
EndIf
WinActivate("Calculator")
$read[1] = FileReadLine("data.txt", 1) 
Send($read[1])
Sleep(100)
If GUICtrlRead($plus) = $GUI_CHECKED Then Send("+")
If GUICtrlRead($minus) = $GUI_CHECKED Then Send("-")
If GUICtrlRead($korda) = $GUI_CHECKED Then Send("*")
If GUICtrlRead($jaga) = $GUI_CHECKED Then Send("/")
Sleep(100)
$read[2] = FileReadLine("data.txt", 2) 
Send($read[2]) 
Sleep(100)
Send("{ENTER}")
;$read[3] = FileReadLine("data.txt", 3) 
;Send($read[3]) 

EndSelect

Until $msg = $GUI_EVENT_CLOSE

autoit can do all the calculations without running the calculator also

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.