Jump to content

Won't restart the loop


Hackerr
 Share

Recommended Posts

#include <Misc.au3>
;
HotKeySet("!a", "Main") ;wait for ALT-a keystroke, then go to Main()
   While 1 ;loop forever to wait for the keypress
      Sleep(1000) ;no need to kill the CPU
   WEnd
Func Main()
  HotKeySet("!a") ;remove the hotkey so we don't jump around once we have started
 ;you start your script here
 $checkWin = WinExists ("Notepad")
   if $checkWin=1 then blurb()
EndFunc
Func blurb()
   $Stop=True
      While 1

     If _IsPressed(11) Then $Stop= False
        Switch $Stop
           Case True
              sleep(1000)
              send("blurb")
            Case False then ExitLoop
         EndSwitch
      WEnd
   Call("Start()")
EndFunc
Func Start()
   $Stop=False
   $quit=False
   While 1 ;loop forever to wait for the keypress
      Sleep(1000) ;no need to kill the CPU
      if _IsPressed(14) Then $Stop=True
         Switch ($Stop)
            case True then ExitLoop
         EndSwitch
      if _IsPressed(11) And _IsPressed(12) then $quit=True
         Switch ($quit)
            case True then Exit
         EndSwitch
   WEnd
   Call("blurb()")
   EndFunc

 

 

I seem to be able to get out of the first loop, the one that keeps saying blurb, but after that it seems to either not go to the start function, or the start function does something wrong.

Link to comment
Share on other sites

Please post code inside code tags and don't start second topics about the same problem. Looking at what you have written I see many mistakes. Switch statements do not use the ketword Then. Before going ny further, whatever you are trying to do is the wrong approach. Your jungle is so overpopulated that you can't see the wood for the trees. In simple English, please describe what it is you are trying to do.

Edited by czardas
Link to comment
Share on other sites

Please post code inside code tags
New rules?

I have had an accident lately and i got operated my eyes. It is very difficult for me to read within code tags.

I also have a friend who has a sickness, which i don't remember it's name, and it is impossible for him to read even normal letters without his glasses.

I don't find this a good recomendation.

Af for the OP. I am really booring.

Here you go. BTW your script is a mess...

#include <Misc.au3>

Global $Stop

HotKeySet("!a", "Main")

HotKeySet("e", "_exit")

While 1

Sleep(100)

WEnd

Func Main()

HotKeySet("!a") ;Once you exit Main() you will not be able to restart it again

$checkWin = WinExists("[CLASS:Notepad]")

If $checkWin = 1 Then

blurb()

EndIf

EndFunc

Func blurb()

$Stop = True

While 1

If _IsPressed("11") Then

$Stop = False

EndIf

Switch $Stop

Case True

sleep(100)

ControlSend("[CLASS:Notepad]", "", "Edit1", "blurb")

Case False

ExitLoop

EndSwitch

WEnd

Call("Start")

EndFunc

Func Start()

$Stop = False

$quit = False

While 1

Sleep(10)

if _IsPressed("14") Then $Stop = True

Switch $Stop

case True

ExitLoop

EndSwitch

if _IsPressed("11") And _IsPressed("12") then $quit = True

Switch $quit

case True

Exit

EndSwitch

WEnd

Call("blurb")

EndFunc

Func _exit()

Exit

EndFunc

Link to comment
Share on other sites

Please post code inside code tags

New rules?

I have had an accident lately and i got operated my eyes. It is very difficult for me to read within code tags.

I also have a friend who has a sickness, which i don't remember it's name, and it is impossible for him to read even normal letters without his glasses.

I don't find this a good recomendation.

 

Not rules but simply a request. It is good advice because reading syntax highlighted code is easier for most people. Furthermore correct indentation is useful to spot issues with nesting. Making your code more readable is going to get more responce. If you have an issue with the colours then use the popup option to read the code in b/w.

Link to comment
Share on other sites

Not rules but simply a request.

A request? I don't request things from people when i want to help them, i just help them.

It is good advice because reading syntax highlighted code is easier for most people. Furthermore correct indentation is useful to spot issues with nesting. Making your code more readable is going to get more responce.

Yep, that's why someone who didn't found it readable and not highlighted and couldn't spot the errors helped him and someone else spend 5 minutes to write 2 requesting posts instead of spending 1 minute to help him ;)

Anyway good luck everyone.

Link to comment
Share on other sites

A request? I don't request things from people when i want to help them, i just help them.

Yep, that's why someone who didn't found it readable and not highlighted and couldn't spot the errors helped him and someone else spend 5 minutes to write 2 requesting posts instead of spending 1 minute to help him ;)

Anyway good luck everyone.

 

AutID, I spent more than 5 minutes looking at the code and gave up trying to understand it. I don't personally care how people post their code. The request is a general request frequently made by forum members. That is the presentation most people prefer and it is good advice to use the forum features which were created for this purpose, even though I am aware some of the features have unresolved issues.

Edited by czardas
Link to comment
Share on other sites

your code is very redundant. for example:

if _IsPressed(14) Then $Stop=True
         Switch ($Stop)
            case True then ExitLoop
         EndSwitch
      if _IsPressed(11) And _IsPressed(12) then $quit=True
         Switch ($quit)
            case True then Exit
         EndSwitch

 

you have 6 lines of code that is not needed. both of these if statements can be 1 line each:

if _IsPressed(14) Then ExitLoop
if _IsPressed(11) And _IsPressed(12) Then Exit

 

using switch for true and false is silly. if statements will clean up your code nicely since all you have to do is use an else.

Before:

     If _IsPressed(11) Then $Stop= False
        Switch $Stop
           Case True
              sleep(1000)
              send("blurb")
            Case False then ExitLoop
         EndSwitch

 

After:

     If _IsPressed(11) Then
              sleep(1000)
              send("blurb")
     Else
            ExitLoop
     EndIf
Link to comment
Share on other sites

  • Moderators

Hackerr,

Posting gamebot code as a first post is forgiveable. Opening a new account to ask exactly the same question with the game reference removed is not.

Take a week's holiday to read and digest the Forum rules. If and when you return, please stick to them.

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

Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

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