Sign in to follow this  
Followers 0
KillerSam

Breaking a loop on button press.

6 posts in this topic

#1 ·  Posted (edited)

I am trying to create a program that will send a message that is entered into an input box to the keyboard, as well as a time delay.

I want to add a pause button, that will pause the script from continuing when pressed, until the start button is pressed, at which point it carries on again.

Global $GUI = GUICreate("Message-auto", 400,120)
$message_tag = GUICtrlCreateLabel("Enter the Message to be sent:", 10,15 ,190)
$Message = GUICtrlCreateInput("", 10, 35, 175, 20)
$Time_tag = GUICtrlCreateLabel("Enter the Time Delay (seconds):", 10, 55, 190)
$Time = GUICtrlCreateInput("", 10,70, 60, 20,$ES_NUMBER)
$Start = GUICtrlCreateButton("Start", 245,55,50)
$Pause = GUICtrlCreateButton("Pause", 305,55,50)
$group_1 = GUICtrlCreateGroup ("", 234, 40,130, 45)
$amount = 0
$amount_display2 = GUICtrlCreateLabel("Times Sent:", 10, 90, 125)
$amount_display = GUICtrlCreateLabel("", 100, 90, 125)
trayTip("Running!", "Version 1.1 - Now running!", 5, 1)
GUISetState(@SW_SHOW)
While 1
        $msg = GUIGetMsg()      
    If  $msg = $GUI_EVENT_CLOSE Then ExitLoop    
    If  $msg = $Start Then
    While 1
    $Time2 = (GUICtrlRead($Time) * 1000)
    $Message2 = (GUICtrlRead($Message))
     sleep ($Time2)
     send ($Message2)
     send ("{ENTER}")
     sleep (500)    
$amount+= 1
GUICtrlSetData($amount_display, $amount)
 WEnd
EndIf
 WEnd

I need it so the pause button will break this loop of actions, then it will continue again when the start button is pressed.

I hope this is enough information

Edited by KillerSam

Share this post


Link to post
Share on other sites



#3 ·  Posted (edited)

I am trying to create a program that will send a message that is entered into an input box to the keyboard, as well as a time delay.

I want to add a pause button, that will pause the script from continuing when pressed, until the start button is pressed, at which point it carries on again.

Global $GUI = GUICreate("Message-auto", 400,120)
$message_tag = GUICtrlCreateLabel("Enter the Message to be sent:", 10,15 ,190)
$Message = GUICtrlCreateInput("", 10, 35, 175, 20)
$Time_tag = GUICtrlCreateLabel("Enter the Time Delay (seconds):", 10, 55, 190)
$Time = GUICtrlCreateInput("", 10,70, 60, 20,$ES_NUMBER)
$Start = GUICtrlCreateButton("Start", 245,55,50)
$Pause = GUICtrlCreateButton("Pause", 305,55,50)
$group_1 = GUICtrlCreateGroup ("", 234, 40,130, 45)
$amount = 0
$amount_display2 = GUICtrlCreateLabel("Times Sent:", 10, 90, 125)
$amount_display = GUICtrlCreateLabel("", 100, 90, 125)
trayTip("Running!", "Version 1.1 - Now running!", 5, 1)
GUISetState(@SW_SHOW)
While 1
        $msg = GUIGetMsg()      
    If  $msg = $GUI_EVENT_CLOSE Then ExitLoop    
    If  $msg = $Start Then
    While 1
    $Time2 = (GUICtrlRead($Time) * 1000)
    $Message2 = (GUICtrlRead($Message))
     sleep ($Time2)
     send ($Message2)
     send ("{ENTER}")
     sleep (500)    
$amount+= 1
GUICtrlSetData($amount_display, $amount)
 WEnd
EndIf
 WEndoÝ÷ ØÞyØ­²az®±æî¶Ú'Â)en·Øb²Z(¦ÚrبËazx­Â)erí{j¢^Ø^²Ö«µ»­¶â²Þ²Ç")zØb²+ )ߢ¹¶*'þ«¨µáÞ­íý²ÞÁ¬­¡Ú"¶ë"¬µ«^§!wºÚ"µÍÚ[ÛYH    ÑÕRPÛÛÝ[Ë]LÉÝÂÛØ[    ÌÍÚTÝ]BÛØ[    ÌÍÑÕRHHÕRPÜX]J    ][ÝÓYÜØYÙKX]]É][ÝË
L
BÌÍÛYÜØYÙWÝYÈHÕRPÝÜX]SX[
    ][ÝÑ[HYÜØYÙHÈHÙ[][ÝËLMHNL
BÌÍÓYÜØYÙHHÕRPÝÜX]R[]
    ][ÝÉ][ÝËLÍKMÍK
BÌÍÕ[YWÝYÈHÕRPÝÜX]SX[
    ][ÝÑ[H[YH[^H
ÙXÛÛÊN][ÝËL
MKNL
BÌÍÕ[YHHÕRPÝÜX]R[]
    ][ÝÉ][ÝËL
Ì
    ÌÍÑT×ÓSPTBÌÍÔÝHÕRPÝÜX]P]Û  ][ÝÔÝ    ][ÝË
K
MK
L
BÌÍÔ]ÙHHÕRPÝÜX]P]Û  ][ÝÔ]ÙI][ÝËÌ
K
MK
L
BÕRPÝÙ]Ý]J  ÌÍÔ]ÙK  ÌÍÑÕRWÑTÐPJBÌÍÙÜÝÌHHÕRPÝÜX]QÜÝ
    ][ÝÉ][ÝËÍ
LÌ

JBÌÍØ[[Ý[ÙÜ^LHÕRPÝÜX]SX[
    ][ÝÕ[YÈÙ[][ÝËLLLJBÌÍØ[[Ý[ÙÜ^HHÕRPÝÜX]SX[
    ][ÝÉ][ÝËLLLJB^U
    ][ÝÔ[[ÉÌÌÎÉ][ÝË    ][ÝÕÚ[ÛKHHÝÈ[[ÉÌÌÎÉ][ÝË
KJBÕRTÙ]Ý]JÕ×ÔÒÕÊBÌÍØ[[Ý[HÌÍÚTÝ]HHÌÍÚU[YHHÚ[HB ÌÍÛÙÈHÕRQÙ]ÙÊ
BÝÚ]Ú    ÌÍÛÙÂØÙH ÌÍÔÝ    ÌÍÚTÝ]HHBÕRPÝÙ]Ý]J  ÌÍÔÝ    ÌÍÑÕRWÑTÐPJBÕRPÝÙ]Ý]J ÌÍÔ]ÙK  ÌÍÑÕRWÑSPH
BØÙH  ÌÍÔ]ÙB  ÌÍÚTÝ]HHÕRPÝÙ]Ý]J   ÌÍÔÝ    ÌÍÑÕRWÑSPH
BÕRPÝÙ]Ý]J  ÌÍÔ]ÙK  ÌÍÑÕRWÑTÐPJBØÙH ÌÍÑÕRWÑUSÐÓÔÑB^][ÝÚ]ÚÝÚ]Ú    ÌÍÚTÝ]BØÙHB   ÌÍÚU[YHH[Y[]

B   ÌÍÚTÝ]H
ÏHBØÙHY[YY   ÌÍÚU[YJH ÝÏH
ÕRPÝXY
    ÌÍÕ[YJH
L
H[  ÌÍÚTÝ]H
ÏHBØÙHÂÙ[
ÕRPÝXY
    ÌÍÓYÜØYÙJH    [È ][ÝÞÑSTI][ÝÊB  ÌÍÚU[YHH[Y[]

B   ÌÍÚTÝ]H
ÏHBØÙH
Y[YY    ÌÍÚU[YJH ÝÏH
L[  ÌÍØ[[Ý[
ÏHBÕRPÝÙ]]J ÌÍØ[[Ý[ÙÜ^K   ÌÍØ[[Ý[
B   ÌÍÚTÝ]HHB[Y[ÝÚ]ÚÑ[

Edit: Forgot to send the Enter key as per original post.

Edited by PaulIA

Auto3Lib: A library of over 1200 functions for AutoIt

Share this post


Link to post
Share on other sites

Yup, I noticed + sorted that.

Many Many Many thanks for this, so much better than my noob version.

Quite a learning curve to see this script, and certainly something I will learn from.

Once again many thanks,

Sam.

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

I'm going to have to go home and work on this. I see what you want to do, but I can't remember where I saw a example on how to do this. I know you could use GUICtrlSetOnEvent

Edit...someone got it......good thing too...had me scratching my head on how to figure it out. good example on how to do it.

Edited by Volly

Share this post


Link to post
Share on other sites

Yup, I noticed + sorted that.

Many Many Many thanks for this, so much better than my noob version.

Quite a learning curve to see this script, and certainly something I will learn from.

Once again many thanks,

Sam.

You're welcome. If any of it is Greek to you, PM me with what you don't understand.

Auto3Lib: A library of over 1200 functions for AutoIt

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