Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Automatically click a batch file  (Read 14508 times)

0 Members and 1 Guest are viewing this topic.

foxidrive



    Specialist
  • Thanked: 268
  • Experience: Experienced
  • OS: Windows 8
Re: Automatically click a batch file
« Reply #15 on: January 01, 2016, 08:59:56 PM »
I knew what you meant. And like I said, the confusion probably stems from the fact that what you describe simply is not what happens in a typical Windows Install. If I double-click a batch file on my desktop- or the desktop of any of my Windows systems, keyboard input goes to the command prompt window that appears.
That's exactly what happens - and why the question makes absolutely no sense.

That can't be what zask means, because it just doesn't happen in Windows.

like really it's not that hard to understand
I will bet you a puppy that you are not using the code that you showed us :D

...or your Windows is just broken and somehow you never noticed. ;)

zask

    Topic Starter


    Intermediate

    • Experience: Experienced
    • OS: Other
    Re: Automatically click a batch file
    « Reply #16 on: January 02, 2016, 08:27:12 PM »
    I knew what you meant. And like I said, the confusion probably stems from the fact that what you describe simply is not what happens in a typical Windows Install. If I double-click a batch file on my desktop- or the desktop of any of my Windows systems, keyboard input goes to the command prompt window that appears. I do not have to click it unless I intentionally click elsewhere first. I can double-click the batch file, completely let go of the mouse, and type in the command prompt window without clicking it.

    Well i figured since i said type in it without having t click by mouse that you would automatically understand what i meant

    zask

      Topic Starter


      Intermediate

      • Experience: Experienced
      • OS: Other
      Re: Automatically click a batch file
      « Reply #17 on: January 02, 2016, 08:30:58 PM »
      From this page...
      http://www.computerhope.com/sethlp.htm
      Code: [Select]
      @ECHO off
      cls
      :start
      ECHO.
      ECHO 1. Print Hello
      ECHO 2. Print Bye
      ECHO 3. Print Test
      set choice=
      set /p choice=Type the number to print text.
      if not '%choice%'=='' set choice=%choice:~0,1%
      if '%choice%'=='1' goto hello
      if '%choice%'=='2' goto bye
      if '%choice%'=='3' goto test
      ECHO "%choice%" is not valid, try again
      ECHO.
      goto start
      :hello
      ECHO HELLO
      goto end
      :bye
      ECHO BYE
      goto end
      :test
      ECHO TEST
      goto end
      :end
      Is that what he wants?  :D

      yes exactly thank you

      zask

        Topic Starter


        Intermediate

        • Experience: Experienced
        • OS: Other
        Re: Automatically click a batch file
        « Reply #18 on: January 02, 2016, 08:36:25 PM »
        not exactly, im trying to keep the screen focused even when you are in a different window

        zask

          Topic Starter


          Intermediate

          • Experience: Experienced
          • OS: Other
          Re: Automatically click a batch file
          « Reply #19 on: January 02, 2016, 08:47:42 PM »
          The reason is because im trying to do this.

          i have 2 batch files name bat1.bat and bat2.bat.

          when i type in bat1.bat, bat2.bat needs to always be focused so that what ever i type in bat one also types in bat two at the same time.

          i knew this sounds dumb but i thought it could be a cool thing to do if it could be pulled off because it would be easier typing in two consoles at the same time than to have to send this dumb command and start every time or run the bat1.bat inside the bat2.bat.

          @echo off
          title bat1.bat
          set /p "somemessage : "
          echo echo %somemessage% >> bat2.bat
          start bat2.bat



          zask

            Topic Starter


            Intermediate

            • Experience: Experienced
            • OS: Other
            Re: Automatically click a batch file
            « Reply #20 on: January 02, 2016, 10:24:23 PM »
            The reason is because im trying to do this.

            i have 2 batch files name bat1.bat and bat2.bat.

            when i type in bat1.bat, bat2.bat needs to always be focused so that what ever i type in bat one also types in bat two at the same time.

            i knew this sounds dumb but i thought it could be a cool thing to do if it could be pulled off because it would be easier typing in two consoles at the same time than to have to send this dumb command and start every time or run the bat1.bat inside the bat2.bat.

            @echo off
            title bat1.bat
            set /p "somemessage : "
            echo echo %somemessage% >> bat2.bat
            start bat2.bat

            Geek-9pm


              Mastermind
            • Geek After Dark
            • Thanked: 1026
              • Gekk9pm bnlog
            • Certifications: List
            • Computer: Specs
            • Experience: Expert
            • OS: Windows 10
            Re: Automatically click a batch file
            « Reply #21 on: January 02, 2016, 10:38:14 PM »
            A mentioned earlier, batch is not much of monitoring events and external conditions.

            There are a class or group of program tools that do monitor events and signals. Sometimes the signals are called 'Semaphores' ti identify them as a special way to communicate with the operating system  when something happens outside of the computers own world.

            If this is of interest to you, you could read this:
            https://en.wikipedia.org/wiki/Semaphore_%28programming%29
            Quote
            A trivial semaphore is a plain variable that is changed (for example, incremented or decremented, or toggled) depending on programmer-defined conditions. The variable is then used as a condition to control access to some system resource.
            But that is rather simplified...
            Quote
            A useful way to think of a semaphore as used in the real-world systems is as a record of how many units of a particular resource are available, coupled with operations to safely (i.e., without race conditions) adjust that record as units are required or become free, and, if necessary, wait until a unit of the resource becomes available. Semaphores are a useful tool in the prevention of race conditions; however, their use is by no means a guarantee that a program is free from these problems. Semaphores which allow an arbitrary resource count are called counting semaphores,
            And it gets more involved...
            Quote
            Semaphores vs. mutexes
            A mutex is essentially the same thing as a binary semaphore and sometimes uses the same basic implementation. The differences between them are in how they are used. While a binary semaphore may be used as a mutex, a mutex is a more specific use-case, which allows extra guarantees:
                Since only the process that locked the mutex is supposed to unlock it, a mutex may store the id of process that locked it and verify the same process unlocks it.
                Mutexes may provide priority inversion safety. If the mutex knows who locked it and is supposed to unlock it, it is possible to promote the priority of that process whenever a higher-priority task starts waiting on the mutex.
                Mutexes may also provide deletion safety, where the process holding the mutex cannot be accidentally deleted.
                A mutex may be recursive: a process is allowed to lock it multiple times without causing a deadlock.
            Someday in the future you will pick up the microphone and tell your computer:
            "Please click on the batch files I want to click, but not the ones that don't work."
            But the programming tool needed will be more  than  just batch.

            BC_Programmer


              Mastermind
            • Typing is no substitute for thinking.
            • Thanked: 1140
              • Yes
              • Yes
              • BC-Programming.com
            • Certifications: List
            • Computer: Specs
            • Experience: Beginner
            • OS: Windows 11
            Re: Automatically click a batch file
            « Reply #22 on: January 03, 2016, 08:24:58 PM »
            Well i figured since i said type in it without having t click by mouse that you would automatically understand what i meant

            There is nothing to "understand". It's gibberish. It's like saying "When I click a button in the taskbar, is there a way to type in the window without clicking it?". It makes no sense as a question because The actions you listed already result in exactly what you described as the desired end result.

            When you click a batch file, the window that launches will *already* have the focus. You don't need to simulate a mouse click. If you are getting different behaviour than your install is borked.
            I was trying to dereference Null Pointers before it was cool.

            Geek-9pm


              Mastermind
            • Geek After Dark
            • Thanked: 1026
              • Gekk9pm bnlog
            • Certifications: List
            • Computer: Specs
            • Experience: Expert
            • OS: Windows 10
            Re: Automatically click a batch file
            « Reply #23 on: January 03, 2016, 10:48:32 PM »
            Ir seems others have the same kind of vocabulary. Just not sure if it is English.
            A Google search for:
            Automatically click a batch file

            Brings up lost of posts that sound similar to what the OP said.
            Following some suggestions, we find this:
            Quote
            Search Results

                    Schedule a Batch File to run automatically
                        Step 1: Create a batch file you wish to run and place it under a folder where you have enough permissions. ...
                        Step 2: Click on Start and under search, type in Task and click open Task Scheduler.
                        Step 3: Select Create Basic Task from the Action pane on the right of the window.

            Which simply says you make it a task to be run automatically. Presently , the task schedule is driven by the clock. So it is the clock that does the click. Perhaps somebody will develop a device to sense brain waves and click on the batch when you think about it.

            Here is a tutorial for Task Manager:
            How to Use Task Manager - PCWorld

            Windows 10 has a feature that tries to learn your habits.
            Cortana (software) - Wikipedia
            Quote
            Cortana is an intelligent personal assistant created by Microsoft for Windows Phone 8.1, Windows 10 Mobile (where it now supersedes Bing Mobile),[4] Microsoft Band, Xbox One,[5][6] Windows 10, iOS and Android.[7]

            Cortana was demonstrated for the first time at the Microsoft BUILD Developer Conference (April 2–4, 2014) in San Francisco.[1] It has been launched as a key ingredient of Microsoft's planned "makeover" of the future operating systems for Windows Phone and Windows.[4] It is named after Cortana,[8] a synthetic intelligence character in Microsoft's Halo video game franchise originating in Bungie folklore,[9] with Jen Taylor, the character's voice actress, returning to voice the personal assistant's US-specific version.[10]
            Maybe  that is what Zask wants. A personal helper.  :)

            BC_Programmer


              Mastermind
            • Typing is no substitute for thinking.
            • Thanked: 1140
              • Yes
              • Yes
              • BC-Programming.com
            • Certifications: List
            • Computer: Specs
            • Experience: Beginner
            • OS: Windows 11
            Re: Automatically click a batch file
            « Reply #24 on: January 03, 2016, 10:59:23 PM »
            They don't want to automatically click a batch file, despite their topic title. They want to automatically click the batch window programmatically to give it focus. a Redundant operation because it already has focus when it launches on any Windows install that isn't borked.
            I was trying to dereference Null Pointers before it was cool.

            Geek-9pm


              Mastermind
            • Geek After Dark
            • Thanked: 1026
              • Gekk9pm bnlog
            • Certifications: List
            • Computer: Specs
            • Experience: Expert
            • OS: Windows 10
            Re: Automatically click a batch file
            « Reply #25 on: January 04, 2016, 12:01:30 AM »
            BC_Programmer,
             Do you mean he thinks he has  to click again to get focus?
            In that case, he wants Widows to do what it does even when he does not understand what it does. So now we must ask, Does the OP now understand?

            (Set to music of 'Just one look..')

            Just one click... that's all it took !
            Just one click... that's all it took !

             :)

            BC_Programmer


              Mastermind
            • Typing is no substitute for thinking.
            • Thanked: 1140
              • Yes
              • Yes
              • BC-Programming.com
            • Certifications: List
            • Computer: Specs
            • Experience: Beginner
            • OS: Windows 11
            Re: Automatically click a batch file
            « Reply #26 on: January 04, 2016, 12:03:31 AM »
            His Windows install is probably borked. Could be a result of him allegedly writing malware and other garbage provided to him by his "professional programming teacher".
            I was trying to dereference Null Pointers before it was cool.

            foxidrive



              Specialist
            • Thanked: 268
            • Experience: Experienced
            • OS: Windows 8
            Re: Automatically click a batch file
            « Reply #27 on: January 04, 2016, 01:34:08 AM »
            It's clear that zask hasn't shown the real code, as he hasn't refuted my comments - and that's the aspect I brought up very quickly in this thread IIRC.

            And which I repeat in every thread where someone wants an accurate answer. but doesn't show an accurate question.



            DaveLembke



              Sage
            • Thanked: 662
            • Certifications: List
            • Computer: Specs
            • Experience: Expert
            • OS: Windows 10
            Re: Automatically click a batch file
            « Reply #28 on: January 04, 2016, 05:34:14 AM »
            Quote
            It's clear that zask hasn't shown the real code, as he hasn't refuted my comments - and that's the aspect I brought up very quickly in this thread IIRC.

            And which I repeat in every thread where someone wants an accurate answer. but doesn't show an accurate question.


            I stayed clear away when I saw this the intent of what they want to do is very shady when they want to hide it...

            Quote
            I know its possible to run the batch script invisible with vbs, is it possible to do this at the same time?

            Reminds me of long ago when people were asking for work arounds for the COLOR command to set the text and background to same color to hide what is going on in DOS and it wouldnt allow it with the color command such as COLOR FF


            zask

              Topic Starter


              Intermediate

              • Experience: Experienced
              • OS: Other
              Re: Automatically click a batch file
              « Reply #29 on: January 04, 2016, 11:16:15 PM »
              They don't want to automatically click a batch file, despite their topic title. They want to automatically click the batch window programmatically to give it focus. a Redundant operation because it already has focus when it launches on any Windows install that isn't borked.

              I want multiple windows to be focused at the same time as the batch windows, for example if i type in google, or on a game or something, it would also type in the batch screen.