Sign in to follow this  
Followers 0
bf2forlife

Calculator without GUI

4 posts in this topic

Can you do calculator like this: It searches for numbers with WinGetText, then when it finds calculation, then it opens notepad and writes the answer?

Share this post


Link to post
Share on other sites

Is this on the internet, a GUI you created or a Window from an exe or???

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

Ok ingore the "without GUI",i just put it there because im too noob to use it. So you create a calculator(with autoIT), then u search the calculation with wingettext, for example. in notepad, then u open another notepad window and write the answer there? Sorry that i did come here with empty hands, this is just pretty new for me.

Share this post


Link to post
Share on other sites

Maybe...

#include <GUIConstantsEx.au3>
#include <ButtonConstants.au3>

Opt("GUIOnEventMode", 1)

Global $SSB = StringSplit("1|2|3|4|5|6|7|8|9|-|0|+|/|*|.|C|%|=", "|"), $bX = 8, $bY = 40

$Form1 = GUICreate("Lc", 108, 233, 193, 125)
GUISetOnEvent($GUI_EVENT_CLOSE, "Close", $Form1)
GUISetBkColor(0xFFFF00)
$som = GUICtrlCreateInput("", 8, 8, 89, 21)
For $i = 1 To $SSB[0]
    GUICtrlCreateButton($SSB[$i], $bX, $bY, 27, 25, $BS_CENTER)
    GUICtrlSetOnEvent(-1, "Event")
    GUICtrlSetFont(-1, 10, 700, 0, "MS Sans Serif")
    If Not Mod($i, 3) Then
        $bX = 8
        $bY += 32
    Else
        $bX += 32
    EndIf
Next
$SSB = 0
GUISetState(@SW_SHOW)

While 1
    Sleep(100)
WEnd

Func Event()
    Switch GUICtrlRead(@GUI_CtrlId)
        Case "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "+", "-", "*", "/", "."
            GUICtrlSetData($som,  GUICtrlRead($som) & GUICtrlRead(@GUI_CtrlId))
        Case "="
            If Execute(GUICtrlRead($som)) Then GUICtrlSetData($som, Execute(GUICtrlRead($som)))
            if Not ProcessExists('notepad.exe') Then Run('notepad.exe')
            WinActivate("Untitled")
            WinWaitActive("Untitled")
            ControlSend("Untitled", "", "Edit1", GUICtrlRead($som)) 
        Case "C"
            GUICtrlSetData($som, "")
        Case "%"
            ;??? Percent, leave this one for you tongue.gif
    EndSwitch
EndFunc

Func Close()
    Exit
EndFunc

... TESTED OK

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  
Followers 0