UltraTM

Learning the Functions

39 posts in this topic

First Hello @all im finally registered :) Thx to the Admin Joe :)

i played also with aut.....ey and autoit. For me autoit is very nice and i made allready some crazy testing stuff with it hehe :)

But one thing i cant get to work for testing. (Im not making an Bot or anything for an game)
I really want to know how something can be done in autoit:

 

in the other thing its like this:
 

*Pause:: ; Pause Taste für pausieren bei einem Fehler evtl.
Suspend
Pause,,1
return

*End:: ; Ende Taste beenden des Keybinders
ExitApp  
return

*F:: ; Taste F
Loop
{
    Send, {a Down}              ;Solange gedrückt drückt er a und d abwechselnd bis man die Taste loslässt zwecks 2 Tasten Funktion etwas anders
            Sleep, 150
              Send, {a Up}
    Send, {d Down}
            Sleep, 150
              Send, {d Up}
}until !GetKeyState("F","P") ;überprüfen ob F oder P losgelassen wurde
return
;Tastenklicker Ende

Its only about to detect an button is pressed as long as its pressed a function run and when its released it stops.

I got it working with an hotkey to start stop with the same key finally :)


But im stuck there.

 

Its really only for testing and learning with simple things first clicking buttons. And one is 2 Keys which should be an loop.
If i would get that running i could start doing more complex stuff. But still cant get only keys work :D

 

 

Thats what i made for testing:

 

While 1
    If _IsPressed("46", $dll) Then
        $pressed = True
        $test = True
        ConsoleWrite("_IsPressed - Shift Key was pressed." & @CRLF)
        ;MsgBox(0, "Pressed", $pressed)
        ; Wait until key is released.
        While _IsPressed("46", $dll)
            Sleep(250)
        WEnd
        $pressed = False
        $test = False
        ConsoleWrite("_IsPressed - Shift Key was released." & @CRLF)
    EndIf
    Sleep(250)
WEnd

Func _start ()
        While 1
            If $pressed = True Then ;Wenn die Variable $aktiv an ist, dann soll
                    Send ("{a down}")
                    Sleep(150);die Taste Space gesendet werden
                    Send ("{a up}")
                    Send ("{d down}")
                    Sleep(150);die Taste Space gesendet werden
                    Send ("{d up}")
            EndIf
        WEnd
EndFunc

Im really trying to convert the code first to understand how its working in autoit. Since the GetKeyState is gone.

 

Greetings :)

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

4 minutes ago, UltraTM said:

Thx to the Admin Joe :)

Joe? ;)

4 minutes ago, UltraTM said:

But one thing i cant get to work for testing. (Im not making an Bot or anything for an game)

Denying something without being asked first normally means the opposite ...  right?

Jos

Edited by Jos

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

Yes sorry was not able to edit it.

Its only cause i also posted it in the german autoit section. And it was being deletet cause of programming a bot...

For me this are simply functions to also learn.
GUI and that is also nice played with it allready :)

Share this post


Link to post
Share on other sites

Ok, let me be clear with you: Make sure you read our forumrules and sick to them and you'll be fine.

Jos

1 person likes this

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

OK
and thank you very much to be a part of the community :)

Share this post


Link to post
Share on other sites
39 minutes ago, UltraTM said:

Thx to the Admin Joe

I think you mean Old Master @Jos! :P

40 minutes ago, UltraTM said:

aut.....ey

??? aut.... wht?


AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Spoiler

My contributions to the AutoIt Community

Some messages & Apologizes:

If I hurt you, Please accept my apologies, I never (regardless of the situation) mean to hurt anybody!!!

Also, I am very busy with my project so I will appear in the last row of the online list, if you want to contact me: Email@TheDcoder.xyz

Or you can have a nice chat with me in freenode, I use the same nick on freenode too!

3fHNZJ.gif

PLEASE JOIN ##AutoIt AND HELP THE IRC AUTOIT COMMUNITY!

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

1 minute ago, TheDcoder said:

??? aut.... wht?

Think and you'll know!

Edited by Jos

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

Yes the Yedi Master :D

autohotkey

Share this post


Link to post
Share on other sites
Just now, Jos said:

Think and you'll know!

@UltraTM has saved me from some thinking :)


AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Spoiler

My contributions to the AutoIt Community

Some messages & Apologizes:

If I hurt you, Please accept my apologies, I never (regardless of the situation) mean to hurt anybody!!!

Also, I am very busy with my project so I will appear in the last row of the online list, if you want to contact me: Email@TheDcoder.xyz

Or you can have a nice chat with me in freenode, I use the same nick on freenode too!

3fHNZJ.gif

PLEASE JOIN ##AutoIt AND HELP THE IRC AUTOIT COMMUNITY!

Share this post


Link to post
Share on other sites

but btw.

Maybe someone could help how i could get this running a function as long as an button is pressed :D

when i insert it in the is_pressed the while. Then its always running and dont get into the check if its still pressed or not.

Share this post


Link to post
Share on other sites

I assume this isn't the total script as this is missing lines at the beginning?
When I add them the trigger with the F key is working fine, so what exactly is the problem?

Jos


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

Hi,

 

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=..\Downloads\dead_by_daylight___icon_by_blagoicons_da5g2xm_il1_icon.ico
#AutoIt3Wrapper_Compile_Both=y
#AutoIt3Wrapper_UseX64=y
#AutoIt3Wrapper_Res_Fileversion=1.0.0.0
#AutoIt3Wrapper_Res_Language=1031
#AutoIt3Wrapper_Res_requestedExecutionLevel=requireAdministrator
#include <Misc.au3>
#include <MsgBoxConstants.au3>


;Hotkeys
HotKeySet ("{f}", "_wechseln") ;Startet die Funktion "_wechseln" beim klicken auf die Pause Taste
HotKeySet ("{END}", "_ende") ;Beendet das Script
;Hotkeys End

Global $aktiv = False ;Deklariere die Variable beim start
Global $pressed = False
Global $test = False

Func _wechseln () ; Funktion _wechseln
    If $aktiv = False Then ;Wechseln des Zustandes der Variable:
        $aktiv = True ;Wenn sie an ist, dann soll sie aus werden
    Else ;wenn das nicht zutrifft, dann
        $aktiv = False ;soll sie aus gehen
    EndIf ;ende der "Wenn" abfrage
EndFunc ;ende der Funktion


;Function start with f and end with f again
;While
;    If $aktiv = True Then ;Wenn die Variable $aktiv an ist, dann soll
;       Send("{a down}") ;Hält a unten
;       Sleep(Random(800, 1100 , 1))
;       Send("{a up}") ;Lässt a los
;       Sleep(Random(10,30, 1))
;       Send("{d down}") ;Hält d unten
;       Sleep(Random(800, 1100 , 1))
;       Send("{d up}") ;Läst d los
;       Sleep(Random(10,30, 1));die Taste Space gesendet werden
;    EndIf ;ende der "Wenn" abfrage
;WEnd


While 1
    If _IsPressed("46") Then
        $pressed = True
        $test = True
        _start()
        ConsoleWrite("_IsPressed - F Key was pressed." & @CRLF)
        ;MsgBox(0, "Pressed", $pressed)
        ; Wait until key is released.
        While _IsPressed("46")
            Sleep(250)
        WEnd
        $pressed = False
        $test = False
        ConsoleWrite("_IsPressed - F Key was released." & @CRLF)
    EndIf
    Sleep(250)
WEnd

Func _start ()
        While 1
            If $pressed = True Then ;Wenn die Variable $aktiv an ist, dann soll
                    Send ("{a down}")
                    Sleep(150);die Taste Space gesendet werden
                    Send ("{a up}")
                    Send ("{d down}")
                    Sleep(150);die Taste Space gesendet werden
                    Send ("{d up}")
            EndIf
        WEnd
EndFunc


Func _stop ()
$test = False
EndFunc

Func _ende () ;Funktion zum beenden
    Exit ;beenden des Skriptes
EndFunc

Thats the actual complete one.
Where i tried to start a function when pressing the button f
it starts but never stops cause he didnt read anymore the code after _start()
Thats where im stuck.
How to use functions there.
to start the function when f button pressed and stop a function when f button released.

Share this post


Link to post
Share on other sites

when i delete it and test it in the editor for example he writes also f and start adadadad but doesnt stop when releasing.
Im to stupid for this :D

tried many different ways but cant find the correct one :D

Share this post


Link to post
Share on other sites

No idea what you are on about, so please simply talk about what you have posted and its result or else you simply confuse the hell out of me.

Jos


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

ok so this is the base function to detect key is pressed and released:

 

While 1
    If _IsPressed("46") Then
        ConsoleWrite("_IsPressed - F Key was pressed." & @CRLF)
        ;MsgBox(0, "Pressed", $pressed)
        ; Wait until key is released.
        While _IsPressed("46")
            Sleep(250)
        WEnd
        ConsoleWrite("_IsPressed - F Key was released." & @CRLF)
    EndIf
    Sleep(250)
WEnd

I only want to know how can i start a function when F Key is pressend and end the function when F key is released for example.
This now only gives me a console message to see ok key pressed and key released.

1 person likes this

Share this post


Link to post
Share on other sites

ok here an example code ive found:

 

#include <misc.au3>
While 1
    If _IsPressed(04) Then ;04 is Middle Click
        Send("{SPACE}")
        While _IsPressed(04) ;04 is Middle Click
            Sleep(10)
        WEnd
    EndIf
    Sleep(10)
WEnd

Problem when press middle mouse it presses 1x space.

How can i make it pressing Space so long until i release the middle mouse button?

Share this post


Link to post
Share on other sites
25 minutes ago, UltraTM said:

How can i make it pressing Space so long until i release the middle mouse button?

That really shouldn't be too hard to figure out when you actually put in the effort to try and understand the posted snippet. ;)

Jos


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

I cant get it even grrr.

The best solution what im looking for is how to start a function as long as its pressed.

think thats why i cant get it work.

In my head theres always start a function with it.
but then it runs.
And the function is also a while loop and it never checks the key released again :(

Share this post


Link to post
Share on other sites

@UltraTM This should print 4 digit random numbers as long as you hold the middle mouse button!

#include <misc.au3>
While 1
    If _IsPressed(04) Then ;04 is Middle Click
        While _IsPressed(04) ;04 is Middle Click
            ConsoleWrite(Random(1000, 9999, 1) & @CRLF)
        WEnd
    EndIf
    Sleep(10)
WEnd

 


AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Spoiler

My contributions to the AutoIt Community

Some messages & Apologizes:

If I hurt you, Please accept my apologies, I never (regardless of the situation) mean to hurt anybody!!!

Also, I am very busy with my project so I will appear in the last row of the online list, if you want to contact me: Email@TheDcoder.xyz

Or you can have a nice chat with me in freenode, I use the same nick on freenode too!

3fHNZJ.gif

PLEASE JOIN ##AutoIt AND HELP THE IRC AUTOIT COMMUNITY!

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