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

  • Similar Content

    • By topgundcp
      Hi, 
      This is my very first post in this forum and am also new with Autoit programming so be easy on me.
      Below is the code that I am trying to get the index of the item selected. No problem getting the text.
      Case $listEdition   ; handle of the list             local $index=0             $item=GUICTRLRead($listEdition)    ; This will return the text in the list             ; ==============   The loop below always fails  ==================             ; Meaning _GUICtrlListView_GetItemSelected($listEdition, $i) always return FALSE. WHY ???????              For $i = 0 To $editionArray[0] - 1   ; The content of the list in an array where editionArray[0] contains total count of items                 If _GUICtrlListView_GetItemSelected($listEdition, $i) Then                     $index = $i                     exitloop                 EndIf              Next              ;===================================================             ConsoleWrite( "Select Edition:     " & $item & "  index: " & $index & @CR) ....... Please look at the comments in the code & the pix attached.
      _GUICtrlListView_GetItemSelected($listEdition, $i) always returns FALSE.
      Another problem is on the list. It also populate  the total count of items from the Array. How can I skip this item from populating to the list ?.
      Please advise and thanks

    • By n0ktar
      is it possible to make a wall chams in rainbow six siege using autoit scripts? tell me please and how . 
    • By Rskm
      Hi, I am using excel as input media for my program. The excel file (i tried with .xls, .xlsx and .xlsm format) has inputs which the autoit script reads during the run and performs few calculations. Some times (not always), after the run, when i try to open the excel file manually, the file doesnt open at all in excel. see the screenshot attached. However, if the execute the autoit script, the scripts still reads the existing data from that excel and performs the calcs. I copied the excel file to another computer and there too, it doesnt open.  So, after this, i cannot edit the excel forever (if i need to change any inputs). It is only this particular file that got affected. other excel files works normal.  What could be the problem here.  please help as this is a new challenge for me during my program development. 

    • By TheAutomator
      Hi everyone!

      I'm using AutoIt for several years now and I really get the hang of it!
      I'm quite the curious OCD perfectionist kind of guy, so I can't help wondering..
      what would be the best way to program stuff for the compiler / interpreter / scripting engine?
      We're talking about the inner workings of the AutoIt's core here, and how to give it as less friction as possible but also take care of the machine running the script.
      For example,
      Imagine a script where we would constantly have to assign a Boolean value to a variable:
      ; A: local $bool = false $bool = true $bool = true $bool = false ; B: local $bool = false check(true) check(true) check(false) func check($b) if $bool = $b then return $bool = $b endfunc In this case, would it be better to just overwrite (A) the variable or first check if we really need to (B)?
      What would be best for the computers memory if it had to do this for a year non stop?
      Another example, imagine you're writing a function with an if statement.
      If you would look under the hood of AutoIt, what would be the best way to give your computer as less work / code nesting stack filling as possible:
      ; A: func decide($b_Input) if $b_Input then ;do something else ;do something else endif endfunc ; B: func decide($b_Input) if $b_Input then ;do something return endif ;do something else endfunc Last one for now:
      ; A: while 1 ; do stuff wend ; B: while true ; do stuff wend Isn't AutoIt taking an extra step in converting 1 to a Boolean in example (A)?
      Or is it the other way around and does the (B) way make AutoIt first convert a keyword (true or false) to a numerical value (0 or 1).
      I think this kinda detail stuff is quite interesting, makes me wonder how AutoIt converts and runs our code.
      What are your opinions on this topic?
      Any coders who know more about the inner workings of AutoIt?
      Any people like me who ask themselves similar questions (with examples)?

      Let me know! 😉
    • By v120
      Rapid Fire Mouse Hack Script
      *snip*
       
×
×
  • Create New...