Jump to content

Looped If


 Share

Recommended Posts

What is wrong with the code below? I would like to get it so that when i press g it chooses to press F1-6 one at a time per each press.

Thanks

HotKeySet("{g}", "Rays")

Func Rays()

Local $Paused = 0

Local $i = 1

While $Paused == 0

Do

If $i = 1 Then

Send("{F1}")

ExitLoop

ElseIf $i = 2 Then

Send("{F2}")

ExitLoop

ElseIf $i = 3 Then

Send("{F3}")

ExitLoop

ElseIf $i = 4 Then

Send("{F4}")

ExitLoop

ElseIf $i = 5 Then

Send("{F5}")

ExitLoop

ElseIf $i = 6 Then

Send("{F6}")

ExitLoop

Else

$i = 1

EndIf

$i = $i + 1

Until $i = 6

WEnd

EndFunc

Link to comment
Share on other sites

  • Moderators

Licam,

HotKeySet("{g}", "Rays")

"Rays"? And what game is this designed to bot? ;)

Did you read the Forum Rules before posting? :)

M23

P.S. If you are a marine biologist and are referring to the Batoidea then I apologise in advance. :D

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

It's pretty hard to determine what the user intends to use this for given the odd function name he chose.

But why is he doing it the way he chose is beyond me.

why not do it something like ~

HotKeySet("{g}", "Rays")
HotKeySet("{esc}", "esc")
Sleep(99999999999)
Func Rays()
    Send("{F1}")
    Sleep(500)
    Send("{F2}")
    Sleep(500)
    Send("{F3}")
    Sleep(500)
    Send("{F4}")
    Sleep(500)
    Send("{F5}")
    Sleep(500)
    Send("{F6}")
    Return
EndFunc   ;==>Rays
Func esc()
    Exit
EndFunc
Link to comment
Share on other sites

  • Moderators

ApudAngelorum,

I am intrigued - what gives you the impression the posting anything helpful in a thread where a Mod has already indicated that it is probably against the Forum rules is a "good idea"? ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

ApudAngelorum,

I am intrigued - what gives you the impression the posting anything helpful in a thread where a Mod has already indicated that it is probably against the Forum rules is a "good idea"? :)

M23

Sorry, I just assumed the use for this wasn't automating a game, it seems weird that he'd want to press those control keys in that order now that you mention it. And since you didn't lock it, I thought it'd be alright, especially since the targeted action is so basic.

And now that the OP hasn't responded at all, it only adds to the probability that this is indeed intended for some kind of game.

Wont happen again~ ;)

Edited by ApudAngelorum
Link to comment
Share on other sites

  • Moderators

ApudAngelorum,

I will only lock a thread if it is against the rules - but it seems sensible to me that others keep out of the thread if a Mod asks someone a question to elicit more information. As I explained in my P.S. to the OP, if he is a marine biologist I would be very happy for the thread to continue as I am actually very fond of those fish (particularly on my plate ;)).

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

It is generalized code where when I press one key, I'd like to be able to have a different key press each time and then loop back through. This is not for a game, but I am working on a repetitive process and just threw this together. This is the first time I have tried to do any coding with AutoIt and was trying to figure out some more of the mechanics as well. Sorry for any confusion with it.

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...