Sign in to follow this  
Followers 0
BALA

Help with GUICtrlCreateInput

7 posts in this topic

#1 ·  Posted (edited)

#include <Misc.au3>
#include <GUIConstants.au3>

Opt("GUIOnEventMode", 1)
$mainwindow = GUICreate("BA-TYPER", 300, 160)
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")
GUISetState()

$position1 = GUICtrlCreateButton("Position", 70, 20, 120)
GUICtrlSetOnEvent($position1, "Position")

$on = GUICtrlCreateRadio ("On", 40, 60, 40, 20)
$off = GUICtrlCreateRadio ("Off", 40, 80, 40, 20)
GUICtrlSetState ($off, $GUI_CHECKED)
$input = GuiCtrlCreateInput("", 80, 70, 180, 20)
$input2 = GUICtrlRead($input)

$time = GuiCtrlCreateInput("5", 180, 107, 40, 20)
$time2 = GUICtrlRead($time)
GUICtrlCreateLabel ("Time between Posts (in seconds)", 10, 110)

Dim $Position, $i = 0, $Record[1][2]
Global $check = 0
Global $time2 = $time2 * 1000

Func CLOSEClicked()
  Exit
EndFunc

Func Position()
  While 1
        If _IsPressed("01") Then
            $Position = MouseGetPos()
            ReDim $Record[$i + 1][2]
            $Record[$i][0] = $Position[0]
            $Record[$i][1] = $position[1]
            consoleWrite($Record[$i][0] & @LF & $Record[$i][ 1] & @LF)
            GUICtrlCreateLabel ("x = "&$Record[$i][0] & @LF & "y = "& $Record[$i][1] & @LF,  200, 20)
            $i += 1
            ExitLoop
        EndIf
        sleep(10)
    WEnd
EndFunc

While 1
    If GUICtrlRead($on) = $GUI_CHECKED Then
        $check = 1
    EndIf
    If GUICtrlRead($off) = $GUI_CHECKED Then
        $check = 0
    EndIf
    If $check = 1 Then
        MouseClick("left", $Position[0], $position[1], 1)
        Send (""&$input2)
        sleep($time2)
    EndIf
    sleep(10)
WEnd

I am trying to create a program that will automatically type a phrase you tell it, over and over until you tell it to stop. For some reason I can't get the input and use that in the Send and Sleep commands near the bottom of the code. Anyone know what I'm doing wrong?

Edited by BALA

[font="Comic Sans MS"]BA-LA[/font]http://ba-la.110mb.comJoin my community, CLICK HEREAlternative links to my site:http://www.ba-la.tkhttp://www.ba-la.co.nrContact me if you would like to help with some of my projects: joeythepirate@gmail.com

Share this post


Link to post
Share on other sites



#include <Misc.au3>
#include <GUIConstants.au3>

Opt("GUIOnEventMode", 1)
$mainwindow = GUICreate("BA-TYPER", 300, 160)
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")
GUISetState()

$position1 = GUICtrlCreateButton("Position", 70, 20, 120)
GUICtrlSetOnEvent($position1, "Position")

$on = GUICtrlCreateRadio ("On", 40, 60, 40, 20)
$off = GUICtrlCreateRadio ("Off", 40, 80, 40, 20)
GUICtrlSetState ($off, $GUI_CHECKED)
$input = GuiCtrlCreateInput("", 80, 70, 180, 20)
$input2 = GUICtrlRead($input)

$time = GuiCtrlCreateInput("5", 180, 107, 40, 20)
$time2 = GUICtrlRead($time)
GUICtrlCreateLabel ("Time between Posts (in seconds)", 10, 110)

Dim $Position, $i = 0, $Record[1][2]
Global $check = 0
Global $time2 = $time2 * 1000

Func CLOSEClicked()
  Exit
EndFunc

Func Position()
  While 1
        If _IsPressed("01") Then
            $Position = MouseGetPos()
            ReDim $Record[$i + 1][2]
            $Record[$i][0] = $Position[0]
            $Record[$i][1] = $position[1]
            consoleWrite($Record[$i][0] & @LF & $Record[$i][ 1] & @LF)
            GUICtrlCreateLabel ("x = "&$Record[$i][0] & @LF & "y = "& $Record[$i][1] & @LF,  200, 20)
            $i += 1
            ExitLoop
        EndIf
        sleep(10)
    WEnd
EndFunc

While 1
    If GUICtrlRead($on) = $GUI_CHECKED Then
        $check = 1
    EndIf
    If GUICtrlRead($off) = $GUI_CHECKED Then
        $check = 0
    EndIf
    If $check = 1 Then
        MouseClick("left", $Position[0], $position[1], 1)
        Send (""&$input2)
        sleep($time2)
    EndIf
    sleep(10)
WEnd

I am trying to create a program that will automatically type a phrase you tell it, over and over until you tell it to stop. For some reason I can't get the input and use that in the Send and Sleep commands near the bottom of the code. Anyone know what I'm doing wrong?

You are using GUICtrlRead to find the checked state of $on but you should use

If GUICtrlGetState($on) = $GUI_CHECKED Then


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

#5 ·  Posted (edited)

Oh, thanks. By the way, sleep(GUICtrlRead($time)) does seem to work for the time, but it does for the input. What's wrong with the time?

That is, time keeps returning a value of 0.

#include <Misc.au3>
#include <GUIConstants.au3>

Opt("GUIOnEventMode", 1)
$mainwindow = GUICreate("BA-TYPER", 300, 160)
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")
GUISetState()

$position1 = GUICtrlCreateButton("Position", 70, 20, 120)
GUICtrlSetOnEvent($position1, "Position")

$on = GUICtrlCreateRadio ("On", 40, 60, 40, 20)
$off = GUICtrlCreateRadio ("Off", 40, 80, 40, 20)
GUICtrlSetState ($off, $GUI_CHECKED)
$input = GuiCtrlCreateInput("", 80, 70, 180, 20)

$time = GuiCtrlCreateInput("5", 180, 107, 40, 20)
GUICtrlCreateLabel ("Time between Posts (in seconds)", 10, 110)

Dim $Position, $i = 0, $Record[1][2]
Global $check = 0
Global $time = $time * 1000

Func CLOSEClicked()
  Exit
EndFunc

Func Position()
  While 1
        If _IsPressed("01") Then
            $Position = MouseGetPos()
            ReDim $Record[$i + 1][2]
            $Record[$i][0] = $Position[0]
            $Record[$i][1] = $position[1]
            consoleWrite($Record[$i][0] & @LF & $Record[$i][ 1] & @LF)
            GUICtrlCreateLabel ("x = "&$Record[$i][0] & @LF & "y = "& $Record[$i][1] & @LF,  200, 20)
            $i += 1
            ExitLoop
        EndIf
        sleep(10)
    WEnd
EndFunc

While 1
    GUICtrlCreateLabel ("Time"&GUICtrlRead($time), 10, 130)
    If GUICtrlGetState($on) = $GUI_CHECKED Then
        $check = 1
    EndIf
    If GUICtrlGetState($off) = $GUI_CHECKED Then
        $check = 0
    EndIf
    If $check = 1 Then
        MouseClick("left", $Position[0], $position[1], 1)
        Send (""&GuiCtrlRead($input))
        sleep(GuiCtrlRead($time))
    EndIf
    sleep(10)
WEnd

I added a label to show the value of $time, and as you can see when your run the program, it keeps showing a value of 0.

Edited by BALA

[font="Comic Sans MS"]BA-LA[/font]http://ba-la.110mb.comJoin my community, CLICK HEREAlternative links to my site:http://www.ba-la.tkhttp://www.ba-la.co.nrContact me if you would like to help with some of my projects: joeythepirate@gmail.com

Share this post


Link to post
Share on other sites

Oh, thanks. By the way, sleep(GUICtrlRead($time)) does seem to work for the time, but it does for the input. What's wrong with the time?

That is, time keeps returning a value of 0.

#include <Misc.au3>
#include <GUIConstants.au3>

Opt("GUIOnEventMode", 1)
$mainwindow = GUICreate("BA-TYPER", 300, 160)
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")
GUISetState()

$position1 = GUICtrlCreateButton("Position", 70, 20, 120)
GUICtrlSetOnEvent($position1, "Position")

$on = GUICtrlCreateRadio ("On", 40, 60, 40, 20)
$off = GUICtrlCreateRadio ("Off", 40, 80, 40, 20)
GUICtrlSetState ($off, $GUI_CHECKED)
$input = GuiCtrlCreateInput("", 80, 70, 180, 20)

$time = GuiCtrlCreateInput("5", 180, 107, 40, 20)
GUICtrlCreateLabel ("Time between Posts (in seconds)", 10, 110)

Dim $Position, $i = 0, $Record[1][2]
Global $check = 0
Global $time = $time * 1000

Func CLOSEClicked()
  Exit
EndFunc

Func Position()
  While 1
        If _IsPressed("01") Then
            $Position = MouseGetPos()
            ReDim $Record[$i + 1][2]
            $Record[$i][0] = $Position[0]
            $Record[$i][1] = $position[1]
            consoleWrite($Record[$i][0] & @LF & $Record[$i][ 1] & @LF)
            GUICtrlCreateLabel ("x = "&$Record[$i][0] & @LF & "y = "& $Record[$i][1] & @LF,  200, 20)
            $i += 1
            ExitLoop
        EndIf
        sleep(10)
    WEnd
EndFunc

While 1
    GUICtrlCreateLabel ("Time"&GUICtrlRead($time), 10, 130)
    If GUICtrlGetState($on) = $GUI_CHECKED Then
        $check = 1
    EndIf
    If GUICtrlGetState($off) = $GUI_CHECKED Then
        $check = 0
    EndIf
    If $check = 1 Then
        MouseClick("left", $Position[0], $position[1], 1)
        Send (""&GuiCtrlRead($input))
        sleep(GuiCtrlRead($time))
    EndIf
    sleep(10)
WEnd

I added a label to show the value of $time, and as you can see when your run the program, it keeps showing a value of 0.

You have got $time as the input, and then you have

Global $time = $time * 1000. ;<---- I think you should delete this line.

Maybe what you want is

sleep(1000 * GUICtrlRead($time))


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

#7 ·  Posted (edited)

Thanks! I think my program's finished now :P

Oh and the early post spammer! made seems to be incorrect, but I fixed the problem.

Edited by BALA

[font="Comic Sans MS"]BA-LA[/font]http://ba-la.110mb.comJoin my community, CLICK HEREAlternative links to my site:http://www.ba-la.tkhttp://www.ba-la.co.nrContact me if you would like to help with some of my projects: joeythepirate@gmail.com

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