Jump to content

Please Help With Short Script..


samtree
 Share

Recommended Posts

Are you sure you don't want:

While 1
    if MouseDown("left") Then send("{enter}")
WEnd

“Give a man a script; you have helped him for today. Teach a man to script; and you will not have to hear him whine for help.”AutoIt4UE - Custom AutoIt toolbar and wordfile for UltraEdit/UEStudio users.AutoIt Graphical Debugger - A graphical debugger for AutoIt.SimMetrics COM Wrapper - Calculate string similarity.

Link to comment
Share on other sites

i think you have to activate a window to send the key to, otherwise, autoit won't know where to apply that {enter}

like...

While 1

if MouseClick("left") Then

winactivate("confirm close", "click ok to close program")

send("{enter}")

endif

WEnd

Link to comment
Share on other sites

john i tryed your script and it doesn't work....all i want it to do is run in the background so i don't notice it and when i click my left mouse it will automatically click it again...

Did you try my script?

While 1
    if MouseDown("left") Then send("{enter}")
WEnd

“Give a man a script; you have helped him for today. Teach a man to script; and you will not have to hear him whine for help.”AutoIt4UE - Custom AutoIt toolbar and wordfile for UltraEdit/UEStudio users.AutoIt Graphical Debugger - A graphical debugger for AutoIt.SimMetrics COM Wrapper - Calculate string similarity.

Link to comment
Share on other sites

I guess this might be what you want...

1. you have a program opened expecting to receive clicks

2. you want to start a script to send a series of clicks to the program

3. you want to have it done in the background

try this see if it suits you

compile clickme.au3 to clickme.exe which simulate 1. above,

make sure both clickme.exe and GoOnClkInBkg.au3 in same folder,

run GoOnClkInBkg.au3 to open clikcme.exe and send 20 clicks to its button,

it will be done in the background, and eventually clickme.exe will close and acknowledge you it's finished.

;clickme.au3 code
#include <GUIConstants.au3>
Dim $a
GUICreate("click me",150,65,200,100)
$b1 = GUICtrlCreateButton("",60,20,30,20)
GUISetState()
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $b1 
            $a = $a +1
            If $a = 20 Then Exit;close after 20 clicks received
        Case $msg = $GUI_EVENT_CLOSE 
            ExitLoop
    EndSelect   
WEnd

;GoOnClkInBkg.au3 code
#include <Constants.au3>
Run("clickme.exe", @ScriptDir, @SW_HIDE)
msgbox(0,"","Start sending click")
For $a  = 1 To 20
    ControlClick ( "click me", "", 3 , "left", 1  )
    If $a = 1 Then WinSetState ( "click me", "", @SW_MINIMIZE  );your target is sent to bkground
    Sleep(500);this delay is for demo only, can be taken away or adjust duration
Next
MsgBox(0, "Done!", "clickme.exe should be closed" )

GoOnClkInBkg.au3

clickme.au3

Link to comment
Share on other sites

I guess this might be what you want...

1. you have a program opened expecting to receive clicks

2. you want to start a script to send a series of clicks to the program

3. you want to have it done in the background

try this see if it suits you

compile clickme.au3 to clickme.exe which simulate 1. above,

make sure both clickme.exe and GoOnClkInBkg.au3 in same folder,

run GoOnClkInBkg.au3 to open clikcme.exe and send 20 clicks to its button,

it will be done in the background, and eventually clickme.exe will close and acknowledge you it's finished.

;clickme.au3 code
#include <GUIConstants.au3>
Dim $a
GUICreate("click me",150,65,200,100)
$b1 = GUICtrlCreateButton("",60,20,30,20)
GUISetState()
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $b1 
            $a = $a +1
            If $a = 20 Then Exit;close after 20 clicks received
        Case $msg = $GUI_EVENT_CLOSE 
            ExitLoop
    EndSelect   
WEnd

;GoOnClkInBkg.au3 code
#include <Constants.au3>
Run("clickme.exe", @ScriptDir, @SW_HIDE)
msgbox(0,"","Start sending click")
For $a  = 1 To 20
    ControlClick ( "click me", "", 3 , "left", 1  )
    If $a = 1 Then WinSetState ( "click me", "", @SW_MINIMIZE  );your target is sent to bkground
    Sleep(500);this delay is for demo only, can be taken away or adjust duration
Next
MsgBox(0, "Done!", "clickme.exe should be closed" )

GoOnClkInBkg.au3

clickme.au3

its alittle confusing.....the script im trying to make does.....well.....all i want is a script thet when i run it iit stays as a syestem icon on the bottom of windows and if i Click my left Mouse button down any were at any thim the script will Click my left mouse button down one more time automatically....

Link to comment
Share on other sites

  • Moderators

its alittle confusing.....the script im trying to make does.....well.....all i want is a script thet when i run it iit stays as a syestem icon on the bottom of windows and if i Click my left Mouse button down any were at any thim the script will Click my left mouse button down one more time automatically....

#include <misc.au3>

While 1
    $Pos = MouseGetPos()
    If _IsPressed('01') Then MouseClick('Left', $Pos[0], $Pos[1], 1, 1)
    Sleep(10)
Wend

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Got Beta?

What is the error you get? You're being horribly vague.

hey im sorry i didnt get to explain the error....but i had to go sum were and i didnt have time.....here are the errors i get.....O and I DONT have Beta!!

Posted Image

This is the ERROR that i get if i just click on it from my desktop...

and this is the ERROR that i get if i run it through Scite....

Click to enlage...

Edited by samtree
Link to comment
Share on other sites

  • Moderators

You are not using Beta: You can download it by running the script in my signature if you don't have it already, or you can use Alt+F5 in SciTe to run the script so that it runs the script in Beta, or you can take out the #include <Misc.au3> and stick this function in script:

Func _IsPressed($s_hexKey, $v_dll = 'user32.dll')
    Local $a_R = DllCall($v_dll, "int", "GetAsyncKeyState", "int", '0x' & $s_hexKey)
    If Not @error And BitAND($a_R[0], 0x8000) = 0x8000 Then Return 1
    Return 0
EndFunc

My suggestion is to make sure you have Beta and use Alt+F5 to run your scripts, because so many things now a days are done with the Beta version rather than the standard 3.1.1 that you will get these errors often if not.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

You are not using Beta: You can download it by running the script in my signature if you don't have it already, or you can use Alt+F5 in SciTe to run the script so that it runs the script in Beta, or you can take out the #include <Misc.au3> and stick this function in script:

Func _IsPressed($s_hexKey, $v_dll = 'user32.dll')
    Local $a_R = DllCall($v_dll, "int", "GetAsyncKeyState", "int", '0x' & $s_hexKey)
    If Not @error And BitAND($a_R[0], 0x8000) = 0x8000 Then Return 1
    Return 0
EndFunc

My suggestion is to make sure you have Beta and use Alt+F5 to run your scripts, because so many things now a days are done with the Beta version rather than the standard 3.1.1 that you will get these errors often if not.

the script runs now but....it doesnt click a second time.....it just doesnt let you double click...

Link to comment
Share on other sites

  • Moderators

clicks twice for me :lmao:

Edit:

Try this code:

While 1
    $Pos = MouseGetPos()
    If _IsPressed('01') Then MouseClick('Right', $Pos[0], $Pos[1], 1, 1)
    Sleep(10)
Wend

Func _IsPressed($s_hexKey, $v_dll = 'user32.dll')
    Local $a_R = DllCall($v_dll, "int", "GetAsyncKeyState", "int", '0x' & $s_hexKey)
    If Not @error And BitAND($a_R[0], 0x8000) = 0x8000 Then Return 1
    Return 0
EndFunc

It will right click after the left click, to show you it's working, you could slow down the speed of the click ... look at MouseClick() in the help file to adjust it properly in the line above.

Try it in Scite or you Desktop to see.

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...