Sign in to follow this  
Followers 0
xxbrentonxx

[STILL NEED HELP] Why wont it work?

22 posts in this topic

#1 ·  Posted (edited)

How come this program wont work?

SCROLL DOWN FOR UPDATED CODE.

Edited by xxbrentonxx

Share this post


Link to post
Share on other sites



You have a few:

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit

Case $Label1
EndSwitch
WEnd

that you dont need, that is keeping it from reaching the script.


[center]Kesne's Bar & Grill[/center]

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

You have a few:

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit

Case $Label1
EndSwitch
WEnd

that you dont need, that is keeping it from reaching the script.

The exit part of WEnd?

Ill go and edit out all the WEnds lol.

Hmm i dont understand, explain?

Edited by xxbrentonxx

Share this post


Link to post
Share on other sites

The exit part of WEnd?

Ill go and edit out all the WEnds lol.

Hmm i dont understand, explain?

WEnd ends your loop.. therefor if you end your loop, it's over... and obviously won't go to the next section of the loop. :)


Global $arr[2]

$arr[0]="hip"
$arr[1]="hip"
;^^ hip hip array. ^^

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

WEnd ends your loop.. therefor if you end your loop, it's over... and obviously won't go to the next section of the loop. :)

Explain still if it doesnt have WEnd and i put it somewhere else it wont work, tell me what i have to remove where?

Now whats wrong, its not pressing the buttons:

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
Global $timerep
Global $sleep
Global $stop
Global $go


#Region ### START Koda GUI section ### Form=c:\program files\autoit3\scite\koda\forms\ressgui.kxf
$Form1_1 = GUICreate("Phantom Ress v0.", 196, 210, 217, 131)
$Label1 = GUICtrlCreateLabel("Phantom Ress ver 0.1 ", 40, 8, 112, 17)
$Label2 = GUICtrlCreateLabel("By brenton", 88, 24, 55, 17)
$go = GUICtrlCreateButton("Start", 48, 144, 89, 25, 0)
GUICtrlSetTip(-1, "Switch to SRO after clicking")
$Label3 = GUICtrlCreateLabel("Key Used For Ress Spell:", 16, 80, 124, 17)
$Label4 = GUICtrlCreateLabel("Times to use Ress spell:", 16, 112, 118, 17)
$keyress = GUICtrlCreateInput("", 144, 80, 41, 21)
GUICtrlSetTip(-1, "0-9")
$stop = GUICtrlCreateButton("Pause", 48, 176, 91, 25, 0)
GUICtrlSetTip(-1, "Pauses the ressing, does not close the program")
$Label5 = GUICtrlCreateLabel("Seconds Paused:", 16, 48, 88, 17)
$sleep = GUICtrlCreateInput("", 144, 48, 41, 21)
$timerep = GUICtrlCreateInput("", 144, 112, 41, 21)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
    Case $GUI_EVENT_CLOSE
Exit

Case $Label1
EndSwitch
WEnd

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit

Case $Label1
EndSwitch
WEnd


While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit


Case $Label1
EndSwitch

WEnd

Dim $var = 0
Func ress ()
    
     Do
    Sleep($sleep)
    Send($keyress, 1)
        $var = $var + 1
    Until $var = $timerep
If $var = $timerep then
    Exit
EndIf 
EndFunc


    Dim $bla = 1
    While 2
    $bla = 1
        Switch $go
    Case $go
    AdlibEnable ("ress")
EndSwitch
Switch $stop
Case $stop
    AdlibDisable ( )
EndSwitch





If $var = $timerep then
    EndIf
WEnd
Edited by xxbrentonxx

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

While 1
$nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
             Exit

        Case $Label1
    EndSwitch
WEndoÝ÷ ÙhbíbµÚ²Ø^²Û~)íì!W¥¢S¯&®¶­sbb33c¶Ò ¥vÆRb33c¶Ò¢b33c¶ä×6rÒuTvWD×6r¢7vF6b33c¶ä×6p¢66Rb33c´uTôUdTåEô4Äõ4P¢b33c¶Ò¢W@ ¢66Rb33c´Æ&Vâb33c¶Ò¢VæE7vF6¥tVæ@

Edited by Flam

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

While 1
$nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
             Exit

        Case $Label1
    EndSwitch
WEndoÝ÷ ÙhbíbµÚ²Ø^²Û~)íì!W¥¢S¯-7ê
That is doing nothing.. Just renders the gui close button useless.

The actual program isnt working still and fckign around with this $GUI_EVENT_CLOSE stuff isnt what needs to be done, im almost positive its in the While 2 or my loop.

Ive changed heaps now, can anyone see whats wrong now?

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
Global $timerep
Global $sleep
Global $stop
Global $go


#Region ### START Koda GUI section ### Form=c:\program files\autoit3\scite\koda\forms\ressgui.kxf
$Form1_1 = GUICreate("Phantom Ress v0.", 196, 210, 217, 131)
$Label1 = GUICtrlCreateLabel("Phantom Ress ver 0.1 ", 40, 8, 112, 17)
$Label2 = GUICtrlCreateLabel("By brenton", 88, 24, 55, 17)
$go = GUICtrlCreateButton("Start", 48, 144, 89, 25, 0)
GUICtrlSetTip(-1, "Switch to SRO after clicking")
$Label3 = GUICtrlCreateLabel("Key Used For Ress Spell:", 16, 80, 124, 17)
$Label4 = GUICtrlCreateLabel("Times to use Ress spell:", 16, 112, 118, 17)
$keyress = GUICtrlCreateInput("", 144, 80, 41, 21)
GUICtrlSetTip(-1, "0-9")
$stop = GUICtrlCreateButton("Pause", 48, 176, 91, 25, 0)
GUICtrlSetTip(-1, "Pauses the ressing, does not close the program")
$Label5 = GUICtrlCreateLabel("Seconds Paused:", 16, 48, 88, 17)
$sleep = GUICtrlCreateInput("", 144, 48, 41, 21)
$timerep = GUICtrlCreateInput("", 144, 112, 41, 21)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

$i = 1

While $i = 1
$nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
             $i = 0
             Exit

        Case $Label1
    EndSwitch
WEnd




Dim $var = 0
Func ress ()
    
     Do
    Sleep($sleep)
    Send($keyress, 1)
        $var = $var + 1
    Until $var = $timerep
If $var = $timerep then
    Exit
EndIf 
EndFunc


    Dim $bla = 1
    While 2
    $bla = 1
        Switch $go
    Case $go
    AdlibEnable ("ress")
Switch $stop
Case $stop
    AdlibDisable ( )




If $var = $timerep then
EndIf
EndSwitch
EndSwitch

WEnd

Ok i fixed with the edited post from Flam but still its as if the variables arent changing or the script isnt reaching the function, im lost -.- .

Edited by xxbrentonxx

Share this post


Link to post
Share on other sites

I just cant seem to get this to work, and everyone is ignoring my post. PLEASE help -.-

Share this post


Link to post
Share on other sites

You need to learn some basics. Like how Switch/Case/EndSwitch works. If you use the same variable as the Case that you passed into Switch, it becomes unconditional to always execute the Case, because no matter what is passed to Switch, the Case is sure to match. Since there is only one Case anyway, why bother with the Switch function at all?

Cleaning up your script before posting would be polite also. Run Tidy and Syntax check before posting so simple typos and silly mistakes can be removed before you post.

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

You need to learn some basics. Like how Switch/Case/EndSwitch works. If you use the same variable as the Case that you passed into Switch, it becomes unconditional to always execute the Case, because no matter what is passed to Switch, the Case is sure to match. Since there is only one Case anyway, why bother with the Switch function at all?

Cleaning up your script before posting would be polite also. Run Tidy and Syntax check before posting so simple typos and silly mistakes can be removed before you post.

:)

I dont know much about BASIC/C, ill try tweaking with the switch and case and post my tidied code too lol.

The reason i have to use Switch and Case is because nobody ever explained to me how i can find if a button has been pressed, and i found it impossible to use Case without switch.

[__CODE_PROTECTED]I2luY2x1ZGUgJiM2MDtCdXR0b25Db25zdGFudHMuYXUzJiM2Mjs8YnIgLz4KI2luY2x1ZGUgJiM2M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AvPgoJU3dpdGNoICYjMDM2O2dvPGJyIC8+CgkJQ2FzZSAmIzAzNjtnbzxiciAvPgoJCQlBZGxpYkVuYWJsZSYjNDA7JiMzNDtyZXNzJiMzNDsmIzQxOzxiciAvPgoJCQlTd2l0Y2ggJiMwMzY7c3RvcDxiciAvPgoJCQkJQ2FzZSAmIzAzNjtzdG9wPGJyIC8+CgkJCQkJQWRsaWJEaXNhYmxlJiM0MDsmIzQxOzxiciAvPgo8YnIgLz4KPGJyIC8+CjxiciAvPgo8YnIgLz4KCQkJCQlJZiAmIzAzNjt2YXIgPSAmIzAzNjt0aW1lcmVwIFRoZW48YnIgLz4KCQkJCQlFbmRJZjxiciAvPgoJCQlFbmRTd2l0Y2g8YnIgLz4KCUVuZFN3aXRjaDxiciAvPgo8YnIgLz4KV0VuZA==[/__CODE_PROTECTED]
Edited by xxbrentonxx

Share this post


Link to post
Share on other sites

The reason i have to use Switch and Case is because nobody ever explained to me how i can find if a button has been pressed, and i found it impossible to use Case without switch.

see http://www.fredosaurus.com/notes-cpp/statements/switch.html. Although the syntax is different, you have to understand the principles of a switch and other things. The same principles apply to just about all programming languages - C++, Java and autoit. Once you understand the principles, applying them to autoit is just a matter of working out the syntax which is in the help file.

Hope that helps.


Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic]

Share this post


Link to post
Share on other sites

see http://www.fredosaurus.com/notes-cpp/statements/switch.html. Although the syntax is different, you have to understand the principles of a switch and other things. The same principles apply to just about all programming languages - C++, Java and autoit. Once you understand the principles, applying them to autoit is just a matter of working out the syntax which is in the help file.

Hope that helps.

Yes ok thanks, but is there a way i can figure out if the button has been pressed without switches? Does it change the variable or something?

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

There is nothing wrong with this use of Switch/Case/EndSwitch:

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $button1
                .; here you would react to $button1 clicked
        Case $button2
                .; here you would react to $button2 clicked
    EndSwitch
WEnd

$nMsg is passed to Switch, and the cases compare that to their values. That's how it's supposed to work.

This makes no sense:

Switch $go
        Case $go
            AdlibEnable("ress")
            Switch $stop
                Case $stop
                    AdlibDisable()




                    If $var = $timerep Then
                    EndIf
            EndSwitch
    EndSwitch

You passed $go (and then $stop) to Switch, but your case compare them to the same thing. How could $go not equal $go? The case is unconditional, it will always be true. Same thing with $stop = $stop. The effective code for this is:

AdlibEnable("ress")
    AdlibDisable()

You unconditionally enable and then immediately disable an AdLib function. Which does nothing.

:)

Edited by PsaltyDS

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

not sure. In normal programming you would have some kind of action listener. Each language has its own implementation, i don't know what autoit has sorry.


Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic]

Share this post


Link to post
Share on other sites

not sure. In normal programming you would have some kind of action listener. Each language has its own implementation, i don't know what autoit has sorry.

If you want that, abandon GuiGetMsg() and use GuiOnEventMode. (See help file.)

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

#16 ·  Posted (edited)

There is nothing wrong with this use of Switch/Case/EndSwitch:

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $button1
                .; here you would react to $button1 clicked
        Case $button2
                .; here you would react to $button2 clicked
    EndSwitch
WEnd

$nMsg is passed to Switch, and the cases compare that to their values. That's how it's supposed to work.

This makes no sense:

Switch $go
        Case $go
            AdlibEnable("ress")
            Switch $stop
                Case $stop
                    AdlibDisable()




                    If $var = $timerep Then
                    EndIf
            EndSwitch
    EndSwitch

You passed $go (and then $stop) to Switch, but your case compare them to the same thing. How could $go not equal $go? The case is unconditional, it will always be true. Same thing with $stop = $stop. The effective code for this is:

AdlibEnable("ress")
    AdlibDisable()

You unconditionally enable and then immediately disable an AdLib function. Which does nothing.

:)

As i have mentioned like 3 times now, i am using the while and case because I DONT KNOW ANY OTHER WAY TO KNOW IF THE BUTTONS BEEN PRESSED.

What should i be changing them too?

What im looking for is if/how clicking the button changes the variable so i can use an If statement.

I tried this

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $button1
                .; here you would react to $button1 clicked
        Case $button2
                .; here you would react to $button2 clicked
    EndSwitch
WEnd

and it just closes my application when the buttons are pressed.

The reason $go wouldnt equal $go was if the button was pressed.

Edited by xxbrentonxx

Share this post


Link to post
Share on other sites

As i have mentioned like 3 times now, i am using the while and case because I DONT KNOW ANY OTHER WAY TO KNOW IF THE BUTTONS BEEN PRESSED.

What should i be changing them too?

What im looking for is if/how clicking the button changes the variable so i can use an If statement.

I tried this

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $button1
                .; here you would react to $button1 clicked
        Case $button2
                .; here you would react to $button2 clicked
    EndSwitch
WEnd

and it just closes my application when the buttons are pressed.

What you're saying doesn't make much sense to me. The code you posted has errors so you can't run it even if you add the missing gui creation etc.

This doesn't make the script end and it's as close as I can get to what you showed

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

#Region ### START Koda GUI section ### Form=
$Form3 = GUICreate("Form3", 413, 298, 303, 219)
$Label1 = GUICtrlCreateLabel("Label1", 56, 32, 36, 17)
$Button1 = GUICtrlCreateButton("Button1", 56, 88, 75, 25, 0)
$Button2 = GUICtrlCreateButton("Button2", 64, 144, 75, 25, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $button1
               ; here you would react to $button1 clicked
        Case $button2
               ; here you would react to $button2 clicked
    EndSwitch
WEnd

Can you post the script you're trying to get to work, give a short clear description of what you want to happen and a short clear description of what you think goes wrong or doesn't work?


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

If you want that, abandon GuiGetMsg() and use GuiOnEventMode. (See help file.)

:)

Thanks for that

Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic]

Share this post


Link to post
Share on other sites

Ok this is my script:

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
Global $timerep
Global $sleep
Global $stop
Global $go


#Region ### START Koda GUI section ### Form=c:\program files\autoit3\scite\koda\forms\ressgui.kxf
$Form1_1 = GUICreate("Phantom Ress v0.", 196, 210, 217, 131)
$Label1 = GUICtrlCreateLabel("Phantom Ress ver 0.1 ", 40, 8, 112, 17)
$Label2 = GUICtrlCreateLabel("By brenton", 88, 24, 55, 17)
$go = GUICtrlCreateButton("Start", 48, 144, 89, 25, 0)
GUICtrlSetTip(-1, "Switch to SRO after clicking")
$Label3 = GUICtrlCreateLabel("Key Used For Ress Spell:", 16, 80, 124, 17)
$Label4 = GUICtrlCreateLabel("Times to use Ress spell:", 16, 112, 118, 17)
$keyress = GUICtrlCreateInput("", 144, 80, 41, 21)
GUICtrlSetTip(-1, "0-9")
$stop = GUICtrlCreateButton("Pause", 48, 176, 91, 25, 0)
GUICtrlSetTip(-1, "Pauses the ressing, does not close the program")
$Label5 = GUICtrlCreateLabel("Seconds Paused:", 16, 48, 88, 17)
$sleep = GUICtrlCreateInput("", 144, 48, 41, 21)
$timerep = GUICtrlCreateInput("", 144, 112, 41, 21)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

$i = 1

While $i = 1
$nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
             $i = 0
             Exit

        Case $Label1
    EndSwitch
WEnd




Dim $var = 0
Func ress ()
    
     Do
    Sleep($sleep) 
    Send($keyress, 1)
        $var = $var + 1
    Until $var = $timerep
If $var = $timerep then
    Exit
EndIf 
EndFunc


    Dim $bla = 1
    While 2
    $bla = 1
        Switch $go
    Case $go
    AdlibEnable ("ress")
Switch $stop
Case $stop
    AdlibDisable ( )




If $var = $timerep then
EndIf
EndSwitch
EndSwitch

WEnd

It runs a gui with 3 fields - sleep, keyress and timerep.

What the program does is sleeps for the value of sleep x 1000 and then sends keyress and adds 1 to var. When var is equal to timerep the program stops. The button $go should start the program after you have set the variables - the program has been named Func Ress.

Whats happening is the buttons dont do anything becuase of the way my While 2 is written.

Share this post


Link to post
Share on other sites

You are tyrying to write something before you understand what you are doing. But you are trying so that is a positive thing. However you must spend more time understanding what is clearly explained in the help, play with the examples and change them. One step at a time.

First here is your script with some comments so you can see where I think you are going wrong.

After that is my version of your script so you can see what I think you should have done. I haven't checked it and I might not understand what you want to do.

Your script with comments

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
Global $timerep
Global $sleep
Global $stop
Global $go


#Region ### START Koda GUI section ### Form=c:\program files\autoit3\scite\koda\forms\ressgui.kxf
$Form1_1 = GUICreate("Phantom Ress v0.", 196, 210, 217, 131)
$Label1 = GUICtrlCreateLabel("Phantom Ress ver 0.1 ", 40, 8, 112, 17)
$Label2 = GUICtrlCreateLabel("By brenton", 88, 24, 55, 17)
$go = GUICtrlCreateButton("Start", 48, 144, 89, 25, 0)
GUICtrlSetTip(-1, "Switch to SRO after clicking")
$Label3 = GUICtrlCreateLabel("Key Used For Ress Spell:", 16, 80, 124, 17)
$Label4 = GUICtrlCreateLabel("Times to use Ress spell:", 16, 112, 118, 17)
$keyress = GUICtrlCreateInput("", 144, 80, 41, 21)
GUICtrlSetTip(-1, "0-9")
$stop = GUICtrlCreateButton("Pause", 48, 176, 91, 25, 0)
GUICtrlSetTip(-1, "Pauses the ressing, does not close the program")
$Label5 = GUICtrlCreateLabel("Seconds Paused:", 16, 48, 88, 17)
$sleep = GUICtrlCreateInput("", 144, 48, 41, 21)
$timerep = GUICtrlCreateInput("", 144, 112, 41, 21)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

$i = 1

; the program cannot get past this while/wend except to exit your script
While $i = 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            $i = 0
            Exit

        Case $Label1
    EndSwitch
WEnd




Dim $var = 0


Func ress()

    Do
        Sleep($sleep)
        Send($keyress, 1)
        $var = $var + 1
    Until $var = $timerep
    #cs 
    If $var = $timerep Then;it will be because we do/until it is
        Exit; I expect you meant return here
    EndIf
    #ce
    return
EndFunc  ;==>ress

;the script never gets to this part 
Dim $bla = 1
While 2
    $bla = 1
    Switch $go;This nmakes no sense
        Case $go;it will always be this case 
            AdlibEnable("ress")
            Switch $stop;same problem
                Case $stop;it will always be this case
                    AdlibDisable();the AdLibEnable is now immediately desabled




                    If $var = $timerep Then
                    EndIf
            EndSwitch
    EndSwitch

WEnd

My version

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
Global $timerep
Global $sleep
Global $stop
Global $go


#Region ### START Koda GUI section ### Form=c:\program files\autoit3\scite\koda\forms\ressgui.kxf
$Form1_1 = GUICreate("Phantom Ress v0.", 196, 210, 217, 131)
$Label1 = GUICtrlCreateLabel("Phantom Ress ver 0.1 ", 40, 8, 112, 17)
$Label2 = GUICtrlCreateLabel("By brenton", 88, 24, 55, 17)
$go = GUICtrlCreateButton("Start", 48, 144, 89, 25, 0)
GUICtrlSetTip(-1, "Switch to SRO after clicking")
$Label3 = GUICtrlCreateLabel("Key Used For Ress Spell:", 16, 80, 124, 17)
$Label4 = GUICtrlCreateLabel("Times to use Ress spell:", 16, 112, 118, 17)
$keyress = GUICtrlCreateInput("", 144, 80, 41, 21)
GUICtrlSetTip(-1, "0-9")
$stop = GUICtrlCreateButton("Pause", 48, 176, 91, 25, 0)
GUICtrlSetTip(-1, "Pauses the ressing, does not close the program")
$Label5 = GUICtrlCreateLabel("Seconds Paused:", 16, 48, 88, 17)
$sleep = GUICtrlCreateInput("", 144, 48, 41, 21)
$timerep = GUICtrlCreateInput("", 144, 112, 41, 21)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

$i = 1

Global $stopit = False;to stop the ress function

While $i = 1
    $nMsg = GUIGetMsg();get the message if any
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            $i = 0
            Exit
        Case $go;the message was from the go button
            AdlibEnable("ress")
            
        Case $stop;the message was from th estop button
            AdlibDisable();
            $stopit = True;make the function ress stop working

        Case $Label1
    EndSwitch
WEnd


Func ress()
    Local $tsleep = Number(GUICtrlRead($sleep))
    If $tsleep = 0 Then;trap empty input
        MsgBox(262144, "ERROR", "Please enter the seconds pause")
        return
    EndIf
    
    Local $key = GUICtrlRead($keyress)
;add another trap here for empty input
    Local $tt = GUICtrlRead($timerep)
;add another trap here for empty input
    Local $var
    Do
        Sleep($tsleep)
        Send($keyress, 1)
        $var = $var + 1
    Until $var = $tt Or $stopit
    $stopit = False
    
    Return
EndFunc  ;==>ress

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

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