Sign in to follow this  
Followers 0
seife96

Help me with gui button!!!

3 posts in this topic

hey i am new in this forum an i programm auto it sice 6 weeks!

i have a question: "i want to do a programm where i can type in 2 messages in an input and then it sends these massages with a button after anoughter in the active window. i have searched bun nothing makes sence. And i dont know how to handle the button! Pleas help me.

GuiCreate("first try",451,457,298,82)
$button1=GuiCtrlCreateButton("start",72,107,180,89)
$button2=GuiCtrlCreateButton("stop",185,290,27,17)
$input1=GuiCtrlCreateInput("massage 1",70,33,27,20)
$input2=GuiCtrlCreateInput("massage 2",72,67,203,20)
GuiSetState()

While 1
$msg=GuiGetMsg()
If $msg=-3 Then Exit
If $msg=$button1 Then button1()
If $msg=$button2 Then button2()
Wend


if $button1 = true Then
    Do
    while 1 
        send($input1)
        sleep(1000)
        send($input2)
        sleep(1000)
        WEnd
    Until $button2 = true
    endIf


Func button1()
EndFunc

Func button2()
EndFunc

Share this post


Link to post
Share on other sites



Look here for more details

http://www.autoitscript.com/wiki/Interrupting_a_running_function

Also use ControlSend() instead of Send() because your GUI is Active at time you press buttons.

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

Global $is_running = False

GuiCreate("first try",451,457,298,82)
$button1=GuiCtrlCreateButton("start",72,107,180,89)
$button2=GuiCtrlCreateButton("stop",185,290,27,17)
$input1=GuiCtrlCreateInput("message 1",70,33,27,20)
$input2=GuiCtrlCreateInput("message 2",72,67,203,20)
GuiSetState()

GUIRegisterMsg($WM_COMMAND, "_WM_COMMAND")

While 1
    $msg=GuiGetMsg()
    If $msg=-3 Then Exit
    If $msg=$button1 Then button1()
    If $msg=$button2 Then button2()
Wend

Func button1()
    Local $msg1, $msg2
    $msg1 = GUICtrlRead($input1)
    $msg2 = GUICtrlRead($input2)
    
    $is_running = True
    while $is_running 
        send($msg1)
        sleep(1000)
        send($msg2)
        sleep(1000)
    WEnd
EndFunc

Func button2()
    $is_running = False
EndFunc

Func _WM_COMMAND($hWnd, $Msg, $wParam, $lParam)
    If BitAND($wParam, 0xFFFF) = $button2 Then $is_running = False
    Return $GUI_RUNDEFMSG
EndFunc

Share this post


Link to post
Share on other sites

Look here for more details

http://www.autoitscript.com/wiki/Interrupting_a_running_function

Also use ControlSend() instead of Send() because your GUI is Active at time you press buttons.

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

Global $is_running = False

GuiCreate("first try",451,457,298,82)
$button1=GuiCtrlCreateButton("start",72,107,180,89)
$button2=GuiCtrlCreateButton("stop",185,290,27,17)
$input1=GuiCtrlCreateInput("message 1",70,33,27,20)
$input2=GuiCtrlCreateInput("message 2",72,67,203,20)
GuiSetState()

GUIRegisterMsg($WM_COMMAND, "_WM_COMMAND")

While 1
    $msg=GuiGetMsg()
    If $msg=-3 Then Exit
    If $msg=$button1 Then button1()
    If $msg=$button2 Then button2()
Wend

Func button1()
    Local $msg1, $msg2
    $msg1 = GUICtrlRead($input1)
    $msg2 = GUICtrlRead($input2)
    
    $is_running = True
    while $is_running 
        send($msg1)
        sleep(1000)
        send($msg2)
        sleep(1000)
    WEnd
EndFunc

Func button2()
    $is_running = False
EndFunc

Func _WM_COMMAND($hWnd, $Msg, $wParam, $lParam)
    If BitAND($wParam, 0xFFFF) = $button2 Then $is_running = False
    Return $GUI_RUNDEFMSG
EndFunc

thank you that helped allot

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