Sign in to follow this  
Followers 0
Zamp

I have two questions.

15 posts in this topic

I am trying to make a program so whenever I press a button it does something, but it never works because right away it closes. How can you make it so it stays open until you right click the icon next to the clock and click close?

And can you make it so if you press a button it like toggles a flag? So if you press, lets say 0, it turns the flag on, and if you press 0 again it turns it off. And then if the flag is on, have it do something, and stop doing it when the flag is off.

I hope that makes sense and someone can help me!

Share this post


Link to post
Share on other sites



No ones going to help you unless you try it first and post your code.


# MY LOVE FOR YOU... IS LIKE A TRUCK- #

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

I am trying to make a program so whenever I press a button it does something, but it never works because right away it closes. How can you make it so it stays open until you right click the icon next to the clock and click close?

And can you make it so if you press a button it like toggles a flag? So if you press, lets say 0, it turns the flag on, and if you press 0 again it turns it off. And then if the flag is on, have it do something, and stop doing it when the flag is off.

I hope that makes sense and someone can help me!

The first one is easy. Put in a While...WEnd loop.

While 1
    Sleep(100)
WEnd

As for the second question, I don't feel like writing up any code showing you how to create a GUI, and then reading the result when a button is pressed, so I will leave that one to someone else with more patience.

Edited by SerialKiller

Share this post


Link to post
Share on other sites

While 1 = 1;make it always stay open
    sleep(100)
    WEnd

$aa = 0 
#include <Misc.au3>

$dll = DllOpen("user32.dll")

If _IsPressed("61", $dll) Then
    $aa + 1
    EndIf
DllClose($dll)
If $aa = 1 then
MsgBox(0, "iiiiii", "kkkk")
EndIf

I tried that and it didn't work. When I pressed 0 nothing happened. I have another question though. Can you have two If statements in a row? So have it be like If _Ispressed("61", $dll) and $aa = 0 Then...

Could you do something like that? And would having $aa + 1 make it so it would only add 1 once?

Share this post


Link to post
Share on other sites

While 1 = 1;make it always stay open
    sleep(100)
    WEnd

$aa = 0 
#include <Misc.au3>

$dll = DllOpen("user32.dll")

If _IsPressed("61", $dll) Then
    $aa + 1
    EndIf
DllClose($dll)
If $aa = 1 then
MsgBox(0, "iiiiii", "kkkk")
EndIf

I tried that and it didn't work. When I pressed 0 nothing happened. I have another question though. Can you have two If statements in a row? So have it be like If _Ispressed("61", $dll) and $aa = 0 Then...

Could you do something like that? And would having $aa + 1 make it so it would only add 1 once?

Question: When will it get past the Wend statement ?

Suggestion: Maybe follow some basic programming course first ?

:whistle:


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Question: When will it get past the Wend statement ?

Suggestion: Maybe follow some basic programming course first ?

:whistle:

I don't know. >_> I just copied what SerialKiller said.

Where could I find a programming course for autoit? I tried looking for one before but couldn't find it. I thought I would just try to go on without one since I thought what I was trying to do would be easy...

Share this post


Link to post
Share on other sites

Thanks that helped a lot! I have a question though. Would this script make it send shift over and over again?

Global $aa
HotKeySet("{F9}", "aa")

While 1
    Sleep(100)
WEnd

Func aa()
    $aa = Not $aa
    While $aa
        Send("+")
        ToolTip("")
    WEnd
    ToolTip("")
EndFunc

I tried making it send "a", and it worked, but then I tried shift and started typing when the function was running, but it was all lower case. Is that because it just doesn't work when you're typing, and it will work when I want it to just keep pressing shift nonstop?

I don't know if that made sense or not. >_> Basically I want it to just keep pressing shift until I stop the function. Will that script do that?

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

Glad to see you learned something from that tutorial ;) that code was very close to what you would need to accomplish what you want, but have you ever heard of the caps-lock key? :whistle:

Global $aa
HotKeySet("{F9}", "aa")

While 1
    Sleep(100)
WEnd

Func aa()
    $aa = Not $aa
    If $aa then Send("{ShiftDOWN}");follow any key with 'Down' and it will hold it until 'Up' is called
    While $aa
         Sleep(500) 
         ToolTip("In Loop",0,0)
    WEnd
    ToolTip("")
    Send("{ShiftUP}")
EndFunc
Edited by Paulie

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

Global $on=False
HotKeySet ("{F9}", "toggleShift")

While 1
Sleep (100)
WEnd

Func toggleShift ( )
$on = Not $on
If $on Then
Send ("{SHIFT DOWN}")
Else
Send ("{SHIFT UP}")
EndIf
EndFunc

not tested but I think it should work...

edit: gah paulie beat me to it

Edited by theguy0000

The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN

Share this post


Link to post
Share on other sites

Caps Lock would work because I'm trying to make an auto attacker thing for a game I play, and you use shift to attack, so I want it to keep pressing shift. >_>

And if I use ShiftDOWN then will it keep pressing shift? Because in the game, if you hold shift then press another button it will stop you from attacking. So it needs to press shift again after it presses the other button. So will shiftdown do that?

Share this post


Link to post
Share on other sites

Caps Lock would work because I'm trying to make an auto attacker thing for a game I play, and you use shift to attack, so I want it to keep pressing shift. >_>

And if I use ShiftDOWN then will it keep pressing shift? Because in the game, if you hold shift then press another button it will stop you from attacking. So it needs to press shift again after it presses the other button. So will shiftdown do that?

No, ShiftDown holds the shift key, which isn't what you want, so use this.

Global $aa
HotKeySet("{F9}", "aa")

While 1
    Sleep(100)
WEnd

Func aa()
    $aa = Not $aa
    While $aa
        Send("{LShift}");The modifier keys that have a left and a right must be specified with a letter
        ToolTip("In Loop",0,0)
    WEnd
    ToolTip("")
EndFunc

Share this post


Link to post
Share on other sites

I tried using LShift then holding down "a" to see if it would make it all caps, and it made some of them caps and some letters were lower case. So I went to try it in my game, but nothing works :whistle: I changed shift to z, just so I could try it in notepad and see if it would keep pressing it, and it worked.

Is there anyway to make AutoIt work with my game?

Share this post


Link to post
Share on other sites

I was looking for something else, one idea that might help is putting some delay between the presses, make it something like a humanly possible speed. Another idea would be to shift down, sleep 20 shift up sleep 100 something like that.


"I'm not even supposed to be here today!" -Dante (Hicks)

Share this post


Link to post
Share on other sites

ugh

What's up Larry? You ever finish that house up and sell it?


"I'm not even supposed to be here today!" -Dante (Hicks)

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
Sign in to follow this  
Followers 0