Jump to content

Recommended Posts

Posted

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. ;)

Posted

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

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
×
×
  • Create New...