obfuscatedv Posted June 12, 2013 Share Posted June 12, 2013 ...without using the "send" command. Once complete-gets the result from the calculator display and show it in a message box (this wont be the difficult part). I just need it to simulate the clicks to add two numbers, but I've hit a total mental block and I'm fairly new to AutoIT. I just commented out the very end where I got stuck so please excuse the sloppiness lol. At that point I was just writing in things to try and refresh any memory I have of coding. Thanks a ton in advance for any assistance.. expandcollapse popupWhile 1 ; Asks user for first number in the adding equation Local $iNum1 = InputBox('Adding!', 'Enter your first number') ; Validates input is a positive integer If $iNum1 < 0 Then MsgBox(0, 'Error', 'Please enter a valid positive integer') Else ExitLoop EndIf WEnd While 2 ; Asks user for second number in the adding equation Local $iNum2 = InputBox('Adding!', 'Enter your second number') ; Validates input is a positive integer If $iNum2 < 0 Then MsgBox(0, 'Error', 'Please enter a valid positive integer') Else ExitLoop EndIf WEnd ; Calculates the two inputs without using "send" command Run('calc.exe', @SystemDir) WinWaitActive('Calculator') ControlClick('Calculator', '', '130') ControlClick('Calculator', '', '131') ControlClick('Calculator', '', '132') ControlClick('Calculator', '', '133') ControlClick('Calculator', '', '134') ControlClick('Calculator', '', '135') ControlClick('Calculator', '', '136') ControlClick('Calculator', '', '137') ControlClick('Calculator', '', '138') ControlClick('Calculator', '', '139') #cs $x = $iNum1 $z = StringLen($x) For $iNum1 = 0 to $z Case 1 Link to comment Share on other sites More sharing options...
DW1 Posted June 12, 2013 Share Posted June 12, 2013 You are close. The control ID numbers should be sent as numbers though, not strings (in other words, do not quote them like that). See if this makes sense expandcollapse popupWhile 1 ; Asks user for first number in the adding equation Local $iNum1 = InputBox('Adding!', 'Enter your first number') ; Validates input is a positive integer If $iNum1 < 0 Then MsgBox(0, 'Error', 'Please enter a valid positive integer') Else ExitLoop EndIf WEnd While 2 ; Asks user for second number in the adding equation Local $iNum2 = InputBox('Adding!', 'Enter your second number') ; Validates input is a positive integer If $iNum2 < 0 Then MsgBox(0, 'Error', 'Please enter a valid positive integer') Else ExitLoop EndIf WEnd ; Calculates the two inputs without using "send" command Run('calc.exe', @SystemDir) WinWaitActive('Calculator') ;Storing the numbers 0-9 in this array Local $aCalcNum[10] = [130,131,132,133,134,135,136,137,138,139] ;Storing control ID for plus and equals Local $iCalcPlus = 93, $iCalcEq = 121 ;Enter the first number For $i = 1 To StringLen($iNum1) ControlClick('Calculator','', $aCalcNum[StringMid($iNum1, $i, 1)]) Next ;Hit plus ControlClick('Calculator','', $iCalcPlus) ;Enter the second number For $i = 1 To StringLen($iNum2) ControlClick('Calculator','', $aCalcNum[StringMid($iNum2, $i, 1)]) Next ;Hit equals ControlClick('Calculator','', $iCalcEq) ;Get visible text from calc window and put in msgbox MsgBox(0,'Answer', WinGetText('Calculator')) AutoIt3 Online Help Link to comment Share on other sites More sharing options...
water Posted June 12, 2013 Share Posted June 12, 2013 Can you please tell us why you need to use calc to calculate the result? My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
Danyfirex Posted June 12, 2013 Share Posted June 12, 2013 Maybe something like this: WinWaitActive("[CLASS:CalcFrame]") ControlClick("[CLASS:CalcFrame]", '', 135) ControlClick("[CLASS:CalcFrame]", '', 93) ControlClick("[CLASS:CalcFrame]", '', 135) ControlClick("[CLASS:CalcFrame]", '', 121) $text = WinGetText("[CLASS:CalcFrame]", "") MsgBox(0, "Texto leído:", $text) I prefer use autoit for maths regards Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
Solution DW1 Posted June 12, 2013 Solution Share Posted June 12, 2013 (edited) Can you please tell us why you need to use calc to calculate the result? I prefer use autoit for maths I guess I was running off the assumption that this was just for the OPs education. Building my own calculator was actually one of the first scripts that I wrote in autoit. I'm hoping this is just a practice in working with another applications controls. Edited June 12, 2013 by danwilli AutoIt3 Online Help Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now