Sign in to follow this  
Followers 0
chronicles

Random with GuiCtrlCreateInput

3 posts in this topic

Hello,

my task is to write an script with a gui input. the script should ask me howmany time i want do send "car", "test", "hello"! These things are working! But the output should be in a random order.

like:

gui:

test 3 times

hello 2 times

car 4 times

random output:

test

hello

test

car

car

test

car

hello

car

i hope i have explained it clear!

bye chronicles from germany

code:

#include <GuiConstants.au3>

If Not IsDeclared('WS_CLIPSIBLINGS') Then Global $WS_CLIPSIBLINGS = 0x04000000

GuiCreate("test", 320, 544, 479,354 ,$WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)

$Label1 = GuiCtrlCreateLabel("Input", 8, 8, 297, 16)

$Label1 = GuiCtrlCreateLabel("Hello:", 8, 96, 116, 16)

$Edit1 = GuiCtrlCreateInput("0", 168, 88, 41, 21)

$Label2 = GuiCtrlCreateLabel("Test:", 8, 128, 138, 16)

$Edit2 = GuiCtrlCreateInput("0", 168, 120, 41, 21)

$Label3 = GuiCtrlCreateLabel("Car:", 8, 160, 153, 16)

$Edit3 = GuiCtrlCreateInput("0", 168, 152, 41, 21)

$btn = GUICtrlCreateButton ("Ok", 168, 170, 40, 40)

GuiSetState()

$msg = 0

While $msg <> $GUI_EVENT_CLOSE

$msg = GUIGetMsg()

Select

Case $msg = $btn

exitloop

EndSelect

Wend

$g = GUICtrlRead($edit1) + GUICtrlRead($edit2) + GUICtrlRead($edit3)

for $h1 = 1 to $g step +1

for $a=1 to GUICtrlRead($edit1) step +1

winActivate ("blubb.txt - Editor") ;

winWaitActive ("blubb.txt - Editor") ;

send ("hello") ;

send ("{ENTER}")

next

for $b=1 to GUICtrlRead($edit2) step +1

winActivate ("blubb.txt - Editor") ;

winWaitActive ("blubb.txt - Editor") ;

send ("test") ;

send ("{ENTER}")

next

for $c=1 to GUICtrlRead($edit3) step +1

winActivate ("blubb.txt - Editor") ;

winWaitActive ("blubb.txt - Editor") ;

send ("car") ;

send ("{ENTER}")

next

next

Share this post


Link to post
Share on other sites



Welcome to the forums!

winActivate ("blubb.txt - Editor");
winWaitActive ("blubb.txt - Editor");

local $helloCount = GUICtrlRead($edit1)
local $testCount = GUICtrlRead($edit2)
local $carCount = GUICtrlRead($edit3)

while ($helloCount > 0 or $testCount > 0 or $carCount > 0)

    $luckyNumber = random(1, 3)
    
    if ($luckyNumber = 1 and $helloCount > 0) then
        send ("hello")
        send ("{ENTER}")
        $helloCount = $helloCount - 1
    elseIf ($luckyNumber = 2 and $testCount > 0) then
        send ("test");
        send ("{ENTER}")
        $testCount = $testCount - 1
    elseIf ($luckyNumber = 3 and $carCount > 0) then
        send ("car");
        send ("{ENTER}")
        $carCount = $carCount - 1
    endIf

wEnd

Share this post


Link to post
Share on other sites

Hi,

Thank You!!! It works fine! :whistle:

First it didn't start, but after I change "$luckyNumber = random(1, 3)" into "$luckyNumber = Int(Random(1, 4))" it works!

bye chronicles

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