Jump to content

Recommended Posts

I have a windows 10 pc and Im trying to create an automatic solving in calculator with a simple worded question (example: What is 45 x 53 ?). thou I cant make the select...Case...EndSelect statement work, here is my code

#include <AutoItConstants.au3>


HotKeySet("{F4}", "ExitProg")

Func ExitProg()
   Exit 0
EndFunc

MouseClick($MOUSE_CLICK_LEFT, 417, 659, 2, 1)
Send("^c")

Func valData()
   $Chek = "What "
   If ClipGet() == $Chek Then
      Check()
      Else
      Do
         MouseClick($MOUSE_CLICK_LEFT, 417, 659, 2, 3)
         Send("^c")
         Sleep(500)
      Until ClipGet() == $Chek

   EndIf
EndFunc

Func Check()
   $Chek2 = "?"
   c1()
   c2()
   c3()
   c4()
   c5()
   c6()
   c7()

   Select
      Case c1() = $Chek2
      ;two
         MouseClick($MOUSE_CLICK_LEFT, 453, 645, 2, 1)
         Send("^c")
         Sleep(150)
         MouseClick($MOUSE_CLICK_LEFT, 1347, 197, 1, 1)
         Send("^v")
         Sleep(150)
         MouseClick($MOUSE_CLICK_LEFT, 474, 645, 2, 1)
         Send("^c")
         Sleep(150)
         MouseClick($MOUSE_CLICK_LEFT, 1347, 197, 1, 1)
         Send("*")
         Send("^v")
         Send("{NUMPADENTER}")
      Case c2() = $Chek2
      ;three
         MouseClick($MOUSE_CLICK_LEFT, 453, 645, 2, 1)
         Send("^c")
         Sleep(150)
         MouseClick($MOUSE_CLICK_LEFT, 1347, 197, 1, 1)
         Send("^v")
         Sleep(150)
         MouseClick($MOUSE_CLICK_LEFT, 482, 645, 2, 1)
         Send("^c")
         Sleep(150)
         MouseClick($MOUSE_CLICK_LEFT, 1347, 197, 1, 1)
         Send("*")
         Send("^v")
         Send("{NUMPADENTER}")
      Case c3() = $Chek2
      ;four
         MouseClick($MOUSE_CLICK_LEFT, 453, 645, 2, 1)
         Send("^c")
         Sleep(150)
         MouseClick($MOUSE_CLICK_LEFT, 1347, 197, 1, 1)
         Send("^v")
         Sleep(150)
         MouseClick($MOUSE_CLICK_LEFT, 487, 645, 2, 1)
         Send("^c")
         Sleep(150)
         MouseClick($MOUSE_CLICK_LEFT, 1347, 197, 1, 1)
         Send("*")
         Send("^v")
         Send("{NUMPADENTER}")
      Case c4() = $Chek2
      ;five
         MouseClick($MOUSE_CLICK_LEFT, 453, 645, 2, 1)
         Send("^c")
         Sleep(150)
         MouseClick($MOUSE_CLICK_LEFT, 1347, 197, 1, 1)
         Send("^v")
         Sleep(150)
         MouseClick($MOUSE_CLICK_LEFT, 495, 645, 2, 1)
         Send("^c")
         Sleep(150)
         MouseClick($MOUSE_CLICK_LEFT, 1347, 197, 1, 1)
         Send("*")
         Send("^v")
         Send("{NUMPADENTER}")
      Case c5() = $Chek2
      ;six
         MouseClick($MOUSE_CLICK_LEFT, 453, 645, 2, 1)
         Send("^c")
         Sleep(150)
         MouseClick($MOUSE_CLICK_LEFT, 1347, 197, 1, 1)
         Send("^v")
         Sleep(150)
         MouseClick($MOUSE_CLICK_LEFT, 495, 645, 2, 1)
         Send("^c")
         Sleep(150)
         MouseClick($MOUSE_CLICK_LEFT, 1347, 197, 1, 1)
         Send("*")
         Send("^v")
         Send("{NUMPADENTER}")
      Case c6() = $Chek2
      ;seven
         MouseClick($MOUSE_CLICK_LEFT, 453, 645, 2, 1)
         Send("^c")
         Sleep(150)
         MouseClick($MOUSE_CLICK_LEFT, 1347, 197, 1, 1)
         Send("^v")
         Sleep(150)
         MouseClick($MOUSE_CLICK_LEFT, 509, 645, 2, 1)
         Send("^c")
         Sleep(150)
         MouseClick($MOUSE_CLICK_LEFT, 1347, 197, 1, 1)
         Send("*")
         Send("^v")
         Send("{NUMPADENTER}")
      Case c7() = $Chek2
      ;eight
         MouseClick($MOUSE_CLICK_LEFT, 453, 645, 2, 1)
         Send("^c")
         Sleep(150)
         MouseClick($MOUSE_CLICK_LEFT, 1347, 197, 1, 1)
         Send("^v")
         Sleep(150)
         MouseClick($MOUSE_CLICK_LEFT, 509, 645, 2, 1)
         Send("^c")
         Sleep(150)
         MouseClick($MOUSE_CLICK_LEFT, 1347, 197, 1, 1)
         Send("*")
         Send("^v")
         Send("{NUMPADENTER}")
      Case Else
         Exit
   EndSelect
EndFunc

Func c1()
   MouseClick($MOUSE_CLICK_LEFT, 485, 643, 2, 1)
   Send("^c")
EndFunc

Func c2()
   MouseClick($MOUSE_CLICK_LEFT, 493, 644, 2, 1)
   Send("^c")
EndFunc

Func c3()
   MouseClick($MOUSE_CLICK_LEFT, 498, 645, 2, 1)
   Send("^c")
EndFunc

Func c4()
   MouseClick($MOUSE_CLICK_LEFT, 508, 647, 2, 1)
   Send("^c")
EndFunc

Func c5()
   MouseClick($MOUSE_CLICK_LEFT, 514, 645, 2, 1)
   Send("^c")
EndFunc

Func c6()
    MouseClick($MOUSE_CLICK_LEFT, 523, 645, 2, 1)
    Send("^c")
EndFunc

Func c7()
   MouseClick($MOUSE_CLICK_LEFT, 530, 645, 2, 1)
   Send("^c")
EndFunc

valData()
MouseClick($MOUSE_CLICK_LEFT, 1349, 196, 1, 1) ;clicking the answer in calc
Send("^c")
Send("{DEL}")
MouseClick($MOUSE_CLICK_LEFT, 499, 706, 1, 1)
Send("^v")
Exit

 

Edited by Melba23
Added code tags

Share this post


Link to post
Share on other sites

None of your functions have a return value, so none of your Select cases are valid. Working as intended, use some type of Return value from the functions and see if it works then.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

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

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By cruisepandey
      Hi There ! 
      I have a script here : 
       
      ;Launch CMD
      Run("C:\Windows\System32\cmd.exe")
      sleep(2000)
      $cmdHandle = WinActivate("C:\Windows\System32\cmd.exe")
      Sleep(2000)
      ;Sending document
      ControlSend($cmdHandle, "", "", "ftp" & @CRLF)
      ControlSend($cmdHandle, "", "", "open" & @CRLF)
      Sleep(2000)
      ControlSend($cmdHandle, "", "", "first command" & @CRLF)
      Sleep(2000)
      ControlSend($cmdHandle, "", "", "second-coomand" & @CRLF)
       
      first-command and second-command I can't provide cause it's internal. I have complied this .au3 file into an exe and it does the work. But I need to invoke this with Java. Java code I have tried is : 
       
          ProcessBuilder pb = new ProcessBuilder("C:\\Users\\username\\eclipse-workspace\\Examples\\src\\com\\own\\examples\\etc.exe");
          pb.start();
          Thread.sleep(5000);
       
      Through java it just launches the cmd and nothing happens after that. Please help !!
    • By FUD
      hello 
      please i need help 
      i need to open link in default browser only one windows without duplicate if i try to open the same link 
       
      thanks 
    • By YogendraAtluri
      Hi, 
      I am new to AutoIT scripting and I am still learning. I am trying to communicate with a Labview application that acts like a server. it basically takes commands from the client. But for some commands, it also send back some data. 
      When i am sending commands from my script, i can see that the labview is getting them. But i am not able to get anything back. I tried different code pieces that are available online in the forum.
      This is the working piece of code which i been using to send data.
      #cs This module is used to establish tcp connection with lab view #ce #include <File.au3> Func SendCmd($cmd) TCPStartup() Local $IpAddress="192.168.10.101" Local $Port="5353" $Labview = TCPConnect($IpAddress,$Port) If @error Then ConsoleWrite('!--> TCPConnect error number ( ' & @error & ' ).' & @CRLF) TCPCloseSocket($Labview) TCPShutdown() Exit EndIf TCPSend($Labview, $cmd & @CRLF) TCPCloseSocket($Labview) TCPShutdown() EndFunc SendCmd("wt42d")  
      This is slightly modified code to send and receive data, which is not working. I am not getting any response back
      SendCmd("galil") Func SendCmd($cmd) TCPStartup() Local $IpAddress="192.168.10.101" Local $Port="5353" $Labview = TCPConnect($IpAddress,$Port) If @error Then ConsoleWrite('!--> TCPConnect error number ( ' & @error & ' ).' & @CRLF) TCPCloseSocket($Labview) TCPShutdown() Exit EndIf TCPSend($Labview, $cmd & @CRLF) $ip = @IPAddress1 ;create listening socket $Listensocket = TCPListen($ip, $Port) ConsoleWrite("Listening to Socket - " & $Listensocket & @CRLF) If $Listensocket = -1 Then ConsoleWrite("Exiting..." & @CRLF) Exit EndIf ;Accept incoming clients and recieve info While 1 $connectedsocket = TCPAccept($Listensocket) ConsoleWrite("Connecting to Socket - " & $connectedsocket & "Error -" & @error & @CRLF) If $ConnectedSocket >= 0 Then $ip2 = TCPRecv($connectedsocket,1000000) EndIf WEnd TCPCloseSocket($connectedsocket) TCPCloseSocket($Labview) TCPShutdown() EndFunc I am not getting anything back. I am getting the following output in the console
      +>Setting Hotkeys...--> Press Ctrl+Alt+Break to Restart or Ctrl+BREAK to Stop. Listening to Socket - 544 Connecting to Socket - -1Error -0 Connecting to Socket - -1Error -0 Connecting to Socket - -1Error -0 Connecting to Socket - -1Error -0 Connecting to Socket - -1Error -0 Connecting to Socket - -1Error -0 Connecting to Socket - -1Error -0 Connecting to Socket - -1Error -0 Connecting to Socket - -1Error -0 its going through that loop forever. i need to force stop it.
      But when i open putty and send the same command, i am getting response right away. 
      Can someone please help me with that.
      Thanks in advance
      Regards
      Yogendra
    • By Bhooshan
      I need to mute an ongoing call on Microsoft teams without activating the window. Teams allows us to mute using shortcut key Ctrl+Shift+m but only when the window is active.
      # Used set option as ongoing call can be with any person which leads to change in Title Name.
      AutoItSetOption ( "WinTitleMatchMode", 2 ) 
      # I am not clear with the control ID which will be good to use here and also the key combination of ^M       
      ControlSend ( "Microsoft Teams", "", "[CLASS:Intermediate D3D Window; INSTANCE:1]", "{ctrl down}")
       
      Can anyone help...!!! 
       

    • By Sayed
      Hi there, 
      I'm new in AutoIt forms and using AutoIt to automate desktop application (able to automate the application normally but facing issue when I've to re-run the application twice within the same script...so need help in this please)
      here is the steps then followed by the issue in a brief : 
      1- run application . 
      2- do some actions (click menus,activate windows,set texts..)
      3- close the application. 
      4- run the application again & access the same controls.
      5- open the same windows again (like step 2)
      6- perform some validations (by getting texts from some text boxes)
      7- close the application again (and repeat 1-7 for 15 times in average )
      The issue 
      * all controls are accessible in the first run and actions done successfully on controls (for steps 1-3) BUT from the second run of the application from step-4 it's able to set focus only the main application window.
      Note: only unique properties used to while mapping the controls. 
      Error that appear in the console :
      UIAWrappers.au3" (1673) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.: $x = Int($t[1] + ($t[3] / 2)) $x = Int($t[1] + (^ ERROR  
      Simple spy code  of one of the controls that has this strange issue(menubar&view menu Item): 
      ;~ *** Standard code maintainable *** #include "UIAWrappers.au3" AutoItSetOption("MustDeclareVars", 1) _UIA_setVar("oP1","Title:=XXX;controltype:=UIA_WindowControlTypeId;class:=WindowsForms10.Window.8.app") ;main app form xxx _UIA_setVar("oP2","Title:=menuStrip1;controltype:=UIA_MenuBarControlTypeId;class:=WindowsForms10.Window.8.app") ;menuStrip1 ;~ $oUIElement=_UIA_getObjectByFindAll("View.mainwindow", "title:=View;ControlType:=UIA_MenuItemControlTypeId", $treescope_subtree) _UIA_setVar("oUIElement","Title:=View;controltype:=UIA_MenuItemControlTypeId;class:=") ;ControlType:=UIA_MenuItemControlTypeId;classname:=") ;~ Actions split away from logical/technical definition above can come from configfiles ;~_UIA_Action("oP1","highlight") _UIA_Action("oP1","setfocus") ;~_UIA_Action("oP2","highlight") _UIA_Action("oP2","setfocus") _UIA_action("oUIElement","highlight") ;~_UIA_action("oUIElement","click")  
       
×
×
  • Create New...