Jump to content
JJ1122

I'm stuck with while/if loop... please help!

Recommended Posts

JJ1122

#include <Misc.au3>

While 1
   If _IsPressed(59) Then
      Send("{B}")
      MouseDown("left")
   Else
      Send("{B}")
      MouseUp("left")
   EndIf
WEnd

 

I want the script to do this:

- if I press "Y", send "B" once and hold left click down until i release "Y".

- if I take my hands off of "Y" key, then send "B" once again and release left click.

 

but the script I made has problems.

when I run the script, it starts sending "B" repeatedly, and my left click won't work.

 

I'm not smart enough to figure out what the problem is... please help me!

sorry for bad English.

 

Edited by JJ1122

Share this post


Link to post
Share on other sites
JLogan3o13

@JJ1122 can you give some more information about what you're trying to do? There is almost always an easier way to accomplish things besides sending mouse clicks.


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites
JJ1122

 

1 hour ago, JLogan3o13 said:

@JJ1122 can you give some more information about what you're trying to do? There is almost always an easier way to accomplish things besides sending mouse clicks.

i want to simplify "press keyboard - press keyboard - click - drag - press keyboard - drop" to "press keyboard - release keyboard".

it's for shopping uses in a korean website.

Share this post


Link to post
Share on other sites
algiuxas
5 hours ago, JJ1122 said:

#include <Misc.au3>

While 1
   If _IsPressed(59) Then
      Send("{B}")
      MouseDown("left")
   Else
      Send("{B}")
      MouseUp("left")
   EndIf
WEnd

 

I see that it checks if a button is pressed, if not, it executes Send("{B}") and MouseUp("left").

If...Else...EndIf Example:

If 1+2=8 Then
    MsgBox(0,"","1+2=8 is correct!"&@CRLF _
    &"That's impossible, so you won't see this message.")
Else
    MsgBox(0,"","1+2=8 is NOT correct!")
EndIF



You may want to try this script:
 

#include <Misc.au3>

While 1
    If _IsPressed(59) Then;Checks if button is pressed
      
      ;If button is pressed, it will execute this script:
      Send("{B}")
      MouseDown("left")

      Do
        Sleep(25)
        ;Sleep until button is released.
      Until Not _IsPressed(59)
      
      ;Execute some script if button is released...
      Send("{B}")
      MouseUp("left")

    EndIf

    Sleep(50);It's always a good idea to add Sleep() to avoid using all CPU usage.
WEnd

I haven't tested this script, but I think it should work.

Edited by algiuxas

42783.png

Share this post


Link to post
Share on other sites
SadBunny

Here is another small example:

#include <Misc.au3>

HotKeySet("{ESC}", "quitter")

$beepFrequency = 300

While True
    If _IsPressed(71) Then
        ConsoleWrite("Started pressing F2" & @CRLF)
        While _IsPressed(71)
            ; Keep increasing the sound frequency while F2 is pressed
            $beepFrequency += 50
            ConsoleWrite($beepFrequency & @CRLF)
            Beep($beepFrequency, 100)
        WEnd
        ConsoleWrite("Stopped pressing F2, resetting frequency and playing single end tone" & @CRLF)
        $beepFrequency = 300
        Beep(150, 300)
    EndIf
WEnd

Func quitter()
    Exit
EndFunc   ;==>quitter

Note that I changed the key to F2 (key 71) to make it easier to test in Scite. Also note that this script will produce sound.

Edited by SadBunny
Fixed comment

Roses are FF0000, violets are 0000FF... All my base are belong to you.

Share this post


Link to post
Share on other sites
algiuxas
#include <Misc.au3>

HotKeySet("{ESC}", "ESC")
Func ESC()
    Exit
EndFunc
ToolTip("Press [ESC] button to stop this script!",0,0,"Press [Y] button!")

$i = False

While 1
    If _IsPressed(59) Then
        Beep(900.0,100)
        Do
        Until Not _IsPressed(59)
        $i = Not $i
        If $i Then
          Send("{B}")
          MouseDown("left")
        Else
          Send("{B}")
          MouseUp("left")
        EndIf
    EndIf
WEnd

You don't need to hold Y button, just press once to hold left mouse button, and when you are done, press Y button again to release left mouse button. :)


42783.png

Share this post


Link to post
Share on other sites
JJ1122
1 hour ago, algiuxas said:
#include <Misc.au3>

HotKeySet("{ESC}", "ESC")
Func ESC()
    Exit
EndFunc
ToolTip("Press [ESC] button to stop this script!",0,0,"Press [Y] button!")

$i = False

While 1
    If _IsPressed(59) Then
        Beep(900.0,100)
        Do
        Until Not _IsPressed(59)
        $i = Not $i
        If $i Then
          Send("{B}")
          MouseDown("left")
        Else
          Send("{B}")
          MouseUp("left")
        EndIf
    EndIf
WEnd

You don't need to hold Y button, just press once to hold left mouse button, and when you are done, press Y button again to release left mouse button. :)

it works just like i wanted! thank you so much

  • Like 1

Share this post


Link to post
Share on other sites
algiuxas
14 minutes ago, JJ1122 said:

it works just like i wanted! thank you so much

I'm happy to help you :)


42783.png

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

    • Docfxit
      By Docfxit
      I would like to know if there is a way to make the send cmd send characters when using
      Graphical AutoIt Debugger By Stumpii,
      If Not WinActive("Setup - UltraVNC","Setup is preparing to install") Then WinActivate("Setup - UltraVNC","Setup is preparing to install") WinWaitActive("Setup - UltraVNC","Setup is preparing to install") Send("{ALTDOWN}f{ALTUP}") ;Finish The debugger when using step mode will execute the Send cmd line but the window doesn't receive the input.
      Thanks,
      Docfxit
    • Aleksandar
      By Aleksandar
      So can anyone help me ? I need to restart program when condition is not met ...

    • PoojaKrishna
      By PoojaKrishna
      Hi friends,
      I'm trying to send SHIFTDOWN, to keep the Shift key pressed until I close the program or releases the key.
      Send ( "{SHIFTDOWN}") sleep(100) $text = InputBox("Shift key down", "Shift key is down. Type something: ") $ret = Msgbox(0,"", "Press and release shift key manually and select [Ok] to continue") $text = InputBox("Shift key up", "Shift key is released manually, now type something: ") Send ( "{SHIFTDOWN}") sleep(100) $text = InputBox("Shift key down Agin", "Shift key is pressed again, now type something: ") In the above program sequence,
      1. Send SHIFTDOWN from program, Works as we type in the text are in Capital letters
      2. Manually presses and releases the SHIFT button. SHIFT key is released as when we type, text is in small letters only.
      3. Again send SHIFTDOWN from program, but not working. When we type the letters are in small letters.
       
      If we send a SHIFTUP  before  sending the SHIFTDOWN again, then it is working correctly and the text appears in capital letters only. Can any one explain why this happens?
      Send ( "{SHIFTDOWN}") sleep(100) $text = InputBox("Shift key down", "Shift key is down. Type something: ") $ret = Msgbox(0,"", "Press and release shift key and select [Ok] to continue") $text = InputBox("Shift key up", "Shift key is released manually, now type something: ") Send ( "{SHIFTUP}") sleep(100) Send ( "{SHIFTDOWN}") sleep(100) $text = InputBox("Shift key down", "Shift key is pressed, now type something: ")  
      Thank you.
    • TheDcoder
      By TheDcoder
      Hello everyone, long time since I made a post in the H&S sub-forum
      I am working on a project where in a situation I would have to hold down an arrow key and release it in another statement/command, however when I wrote the code it isn't working exactly like I thought it would. Here is an example:
      Send("{UP down}") Sleep(10000) Send("{UP up}") This should hold the up arrow key for 10 seconds before releasing it again, but when I run this code the cursor in SciTE moves up only once
      If I hold the up arrow manually for 10 seconds it "repeats" and the cursor moves up several times until I release the key... Is this a known limitation of Send? Is there any other way I can accomplish this?
      Thanks for all the help and feedback in advance! TD
    • badcoder123
      By badcoder123
      Anyone know how to access the information circled in the photo?
       

×