niubbone Posted April 24, 2010 Share Posted April 24, 2010 The program is a simple exercise with a GUI with 3 buttons: 1 opens the notepad and types time and date, then closes it. 2 after giving a first choice between 1 sum, 2 subtraction, 3 multiplication, 4 division, the program asks for 2 operators to execute the operation on, in the default windows calculator, then closes it. 3 Same as nr 1, but writes also OS As u can see here I had various issues (no need to watch it, just if you care) http://www.autoitscript.com/forum/index.php?showtopic=113437 Here's the source: expandcollapse popup#include <GuiConstants.au3> GUICreate("Multiselezione by NATTA",300,230) GUISetState(@SW_SHOW) $bottone1=GUICtrlCreateButton("Opzione 1",10,10) GUICtrlCreateLabel("Aprire il notepad e scrivere l'ora e la data, poi chiuderlo"&@CRLF&"senza salvarlo",15,40) $bottone2=GUICtrlCreateButton("Opzione 2",10,80) GUICtrlCreateLabel("Aprire la calcolatrice e eseguire un calcolo a scelta tra"&@CRLF&"2 operatori con le 4 operazioni di base",15,110) $bottone3=GUICtrlCreateButton("Opzione 3",10,150) GUICtrlCreateLabel("Aprire il notepad, scrivere l'ora e la data, il sistema"&@CRLF&"operativo e chiudere senza salvare",15,180) While 1 $Scelta = GUIGetMsg() If $Scelta = $GUI_EVENT_CLOSE Then ExitLoop Select Case $Scelta=$bottone1 BlockInput(1) Run("notepad.exe") WinWaitActive("Senza nome - Blocco note") Send("Ora e data "&@CRLF&"{F5}") Sleep(1500) WinClose("Senza nome - Blocco note") WinWaitActive("Blocco note") Send("!n") BlockInput(0) Case $Scelta=$bottone2 While 1 While 1 $operatore2=InputBox("Scegliere","1.Moltiplicazione"&@CRLF&"2.Divisione"&@CRLF&"3.Addizione"&@CRLF&"4.Sottrazione") If @error Then ExitLoop If Not StringIsInt($operatore2) or $operatore2<1 or $operatore2>4 Then Msgbox(0, "Errore", "Non hai inserito un numero intero") ContinueLoop Endif ExitLoop Wend While 1 $operatore1=InputBox("Inserire il primo operatore numerico","Primo Operatore:") If @error Then ExitLoop If Not StringIsInt($operatore1) Then Msgbox(0, "Errore", "Non hai inserito un numero intero") ContinueLoop Endif ExitLoop Wend While 1 $operatore3=InputBox("Inserire il primo operatore numerico","Secondo Operatore:") If @error Then ExitLoop If Not StringIsInt($operatore3) Then Msgbox(0, "Errore", "Non hai inserito un numero intero") ContinueLoop Endif ExitLoop Wend BlockInput(1) Run("Calc.exe") WinWaitActive("Calcolatrice") AutoItSetOption("SendKeyDelay",400) Switch $operatore2 Case 1 Send($operatore1&"*"&$operatore3&"=") Case 2 Send($operatore1&"/"&$operatore3&"=") Case 3 Send($operatore1&"+"&$operatore3&"=") Case 4 Send($operatore1&"-"&$operatore3&"=") EndSwitch BlockInput(0) Sleep(6000) WinClose("Calcolatrice") ExitLoop WEnd Case $Scelta=$bottone3 BlockInput(1) Run("notepad.exe") WinWaitActive("Senza nome - Blocco note") Send("Ora e data"&@CRLF&"{F5}"&@CRLF&"Sistema operativo"&@CRLF&@OSVersion) Sleep(1500) Winclose("Senza nome - Blocco note") WinWaitActive("Blocco note") Send("!n") BlockInput(0) EndSelect WEnd But at this point it's 2 days that i reached a point i can't understand a bug the code has. The problem is that for example if I pick choice 3 (Sum) and I input 33 as first operator, and 33 as second operator, the program just types in the windows calculator 333, while the code to send to windows calculator is: Send($operatore1&"+"&$operatore3&"=") How this is possible? I mean, I could understand bad manipulated variables, but there is a "+" and a "=" sent there as strings, unrelated to any other variable.... The correct keystrokes would be 33+33=, and also if the second operator it's changed into s single 3 it should be 33+3=. Instead, autoit doesn't types even the +... I thought it was because autoit typed that too fast (also if there is WinWaitActive) so i put in the code AutoItSetOption("SendKeyDelay", 400) to be sure but the result it's the same.... How this is possible??? Link to comment Share on other sites More sharing options...
goldenix Posted April 24, 2010 Share Posted April 24, 2010 next time make safe example. I tried this & it blocked my key input I was not able to write anything in notepad. there is ctrl+alt+del to unblock it but still, ppl may have important unsaved stuff open & who knows !!!! My Projects:[list][*]Guide - ytube step by step tut for reading memory with autoitscript + samples[*]WinHide - tool to show hide windows, Skinned With GDI+[*]Virtualdub batch job list maker - Batch Process all files with same settings[*]Exp calc - Exp calculator for online games[*]Automated Microsoft SQL Server 2000 installer[*]Image sorter helper for IrfanView - 1 click opens img & move ur mouse to close opened img[/list] Link to comment Share on other sites More sharing options...
JohnOne Posted April 24, 2010 Share Posted April 24, 2010 Try using flag ,1 in your send function to allow raw sending of the keys. read it in the help file AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
niubbone Posted April 24, 2010 Author Share Posted April 24, 2010 next time make safe example. I tried this & it blocked my key input I was not able to write anything in notepad.there is ctrl+alt+del to unblock it but still, ppl may have important unsaved stuff open & who knows !!!!I put BlockInput by purpose. I know also you can unlock it with ctrl+alt+canc. By the way Blockinput was active only while a program is open (notepad or calculator) and not in any other case, and those programs, close themselves automatically, unblocking input. Remove BlockInput Commands from the code if you find it annoying (you already knew it right?).Any solution for the problem? Link to comment Share on other sites More sharing options...
niubbone Posted April 24, 2010 Author Share Posted April 24, 2010 Try using flag ,1 in your send function to allow raw sending of the keys.read it in the help fileThanks! It worked! Didn't knew bout it. Sorry! 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