Sign in to follow this  
Followers 0
Lukepro2315

_IsPressed + loop - is that possible? N Advice

11 posts in this topic

Hi guyz, im trying to make script needs to have _IsPressed command in it, to run some repeating action.

Problem is, that all _IsPressed functions need While 1 / WEnd to work. And in i add some another While / WEnd between existing While / Wend, both will stop work.

Example what i need to do:

While1 (must be here to work)

_IsPressed Then

Some loop (Unfortunately i dont know how to make another loop without While / WEnd - if i place new While here, both stops work)

EndIf

_IsPressed Then

Blabla1

EndIf

_IsPressed Then

Blabla2

EndIf

WEnd (must be)

Can somehow hlp me?

What i planed to do is somehow connect the first _IsPressed function with another one, that is out of this While loop, and make another While loop somewhere else. But im afraid that two of them cant run at once...right?

So can someone hlp me? Or give some advice?

Thx

Share this post


Link to post
Share on other sites



 

Have you looked at AdLibRegister?

#include <Misc.au3>
AdlibRegister("MyFunc")


While 1
    ;Do Stuff
WEnd


Func MyFunc()
    If _IsPressed(01) Then Exit
EndFunc

I did...a little...i thought it have something to do with timing...maybe i didnt understand that well...ill try to read it again and more carefully. :P

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

If you make a loop inside a loop, the second loop will take over... essentially..

While 1
        Going
        X is pressed
             While 1
                Going

This will cause the first loop to essentially freeze, because it's waiting for the second loop to finish.

What key are you wanting to capture?
Can you be more detailed in what you're doing?
Have you looked into hotkeys?

Edited by Sori

If you need help with your stuff, feel free to get me on my Skype.

I often get bored and enjoy helping with projects.

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Well what i have build was something like that:

$countsec1 = 60 ;time set to 60 seconds

While 1
If _IsPressed("70", $hDLL) = 1 Then
;F1 starts counting
While 1 ;-I knw that this one is not suppoed to be here

$countsec1 = $countsec1 -1    ;Countdown by 1 sec to zero

Sleep(1000) ;Every second

EndIf                            

If $countsec1 = 0 Then ;If countdown drops to 0, it will stop and reset back to 60 sec

Exitloop

$countsec1 = 60

Wend

EndIf

If _IsPressed("71", $hDLL) = 1 Then ;F2 type remaining time

Send ("Time left is " & $countsec1 & " till end")

EndIf

WEnd

Its not exactly like it should be...i wrote it in hurry. But b4 i build that trough Hotkeyset function, and it worked. Unfortunately i need that in _IsPressed and dont know how.

All i need is to Press button, and repeat all between While / Wend and another button to show it. But when i make group with _IsPressed, i cant do another loops. :(

And...maybe another button to stop and reset Green loop

Edited by Lukepro2315

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Instead of while 1, do while $countset1 > 0
That way it will exit at 0 for you. (update your count inside the while)

As far as detecting if F2 is pressed during the F1 loop, it will be something like...
While F1

     Looping stuff
     If F2 is pressed

            print scripting
     endif

wend

That way it's checking for F2 during the F1 loop

 

P.S.
Very helpful for us:

When creating a reply, there is a small blue A key, right below the smiley face.
When you want to post Autoit Code, press that blue button, then paste your code into it.

This will automatically format the code into the correct colors and space it accordingly.

Edited by Sori

If you need help with your stuff, feel free to get me on my Skype.

I often get bored and enjoy helping with projects.

Share this post


Link to post
Share on other sites

Is there some reason you can't use hotsetkeys?

Yy i want it in game, and Hotkeys not work there

Share this post


Link to post
Share on other sites

Instead of while 1, do while $countset1 > 0

That way it will exit at 0 for you. (update your count inside the while)

As far as detecting if F2 is pressed during the F1 loop, it will be something like...

While F1

     Looping stuff

     If F2 is pressed

            print scripting

     endif

wend

That way it's checking for F2 during the F1 loop

 

P.S.

Very helpful for us:

When creating a reply, there is a small blue A key, right below the smiley face.

When you want to post Autoit Code, press that blue button, then paste your code into it.

This will automatically format the code into the correct colors and space it accordingly.

Aaah thx for all. Ill try it in work after 7Pm :D (Dont have time now). Hope it will work. :)

Thx for advice

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

Yy i want it in game, and Hotkeys not work there

 

You need to look at the forum rules (bottom right corner of every page) before going any further. Especially the part the prohibits any form of game automation.

Edited by JLogan3o13

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

Share this post


Link to post
Share on other sites

Lukepro2315,

JLogan3o13 is quite right - please read the Forum rules (the link is also at bottom right of each page) - particularly the bit about not discussing game automation - before you post again. Thread locked. :naughty:

But welcome to the AutoIt forum - and see you soon with a legitimate question I hope. :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this  
Followers 0