Sign in to follow this  
Followers 0
Matrix112

Is it AutoIT or a error in my script?

7 posts in this topic

Hi,

i will make a cube number generator, the code is easy, but there is something wrong and i don´t know why.

If i click on shake 2 cube pictures change and one duplicates itself, then the third cube doesn´t change.

There should only be 3 cubes and all should change.

The rar file contains the cube pics.

#include <GuiConstants.au3>
Global $res1
Global $res2
Global $res3
If Not IsDeclared('WS_CLIPSIBLINGS') Then Global $WS_CLIPSIBLINGS = 0x04000000

GuiCreate("Würfel Generator", 338, 216,(@DesktopWidth-338)/2, (@DesktopHeight-216)/2 ,  $WS_VISIBLE + $WS_CAPTION + $WS_SYSMENU + $WS_POPUP + $WS_CLIPSIBLINGS )

$shake = GuiCtrlCreateButton("Shake", 130, 160, 80, 30)
$Pic_1 = GuiCtrlCreatePic("Würfel1.jpg", 30, 40, 60, 60)
$Pic_2 = GuiCtrlCreatePic("Würfel1.jpg", 140, 40, 60, 60)
$Pic_3 = GuiCtrlCreatePic("Würfel2.jpg", 250, 40, 60, 60)

GuiSetState()
While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    case $msg = $shake
        shake3()
        GUICtrlSetImage($pic_1, "Würfel" & $res1 & ".jpg")
        GUICtrlSetImage($pic_2, "Würfel" & $res2 & ".jpg")
        GUICtrlSetImage($pic_3, "Würfel" & $res3 & ".jpg")
        Sleep(10)
    EndSelect
Sleep(30)
WEnd
Exit

Func shake1()
    $res1 = Random(1,6,1)
EndFunc 

Func shake2()
    $res1 = Random(1,6,1)
    $res2 = Random(1,6,1)
EndFunc

Func shake3()
    $res1 = Random(1,6,1)
    $res2 = Random(1,6,1)
    $res3 = Random(1,6,1)
EndFunc

cube_pics.rar

Share this post


Link to post
Share on other sites



This works:

#include <GuiConstants.au3>
Global $res1
Global $res2
Global $res3
Dim $location = 'C:\Documents and Settings\Default\My Documents\My Pictures\'

GuiCreate("Würfel Generator", 338, 216,(@DesktopWidth-338)/2, (@DesktopHeight-216)/2 ,  $WS_VISIBLE + $WS_CAPTION + $WS_SYSMENU + $WS_POPUP + $WS_CLIPSIBLINGS )

$shake = GuiCtrlCreateButton("Shake", 130, 160, 80, 30)
$Pic_1 = GuiCtrlCreatePic($location & "Würfel1.jpg", 30, 40, 60, 60)
$Pic_2 = GuiCtrlCreatePic($location & "Würfel1.jpg", 140, 40, 60, 60)
$Pic_3 = GuiCtrlCreatePic($location & "Würfel2.jpg", 250, 40, 60, 60)

GuiSetState()
While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    case $msg = $shake
        shake3()
        Sleep(10)
    EndSelect
Sleep(30)
WEnd
Exit

Func shake1()
    $res1 = Random(1,6,1)
EndFunc 

Func shake2()
    $res1 = Random(1,6,1)
    $res2 = Random(1,6,1)
EndFunc

Func shake3()
    $res1 = Random(1,6,1)
    $res2 = Random(1,6,1)
    $res3 = Random(1,6,1)
    GUICtrlSetImage($pic_1, $location & "Würfel" & $res1 & ".jpg")
    GUICtrlSetImage($pic_2, $location & "Würfel" & $res2 & ".jpg")
    GUICtrlSetImage($pic_3, $location & "Würfel" & $res3 & ".jpg")
EndFunc

Change the $location to exactly where your pics are if they aren't in the script folder.


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

Smoke_N: Your version gives the same problem when I run it..

Matrix112: Don't know why but when I remove $WS_VISIBLE from the GUICreate() it works fine for me..


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

@Jdeb, Did you BitOr() them (this is actually what I used BitOR($WS_VISIBLE, $WS_CAPTION, $WS_SYSMENU, $WS_POPUP, $WS_CLIPSIBLINGS)), but it worked on my system, after I removed: If Not IsDeclared('WS_CLIPSIBLINGS') Then Global $WS_CLIPSIBLINGS = 0x04000000

I have my 'Beta' Include as my default include... would that make a difference?

Edit: Typo

Edit2: This works too, again.. maybe it's my beta include:

#include <GuiConstants.au3>
Global $res1
Global $res2
Global $res3
Dim $location = 'C:\Documents and Settings\Ron\My Documents\My Pictures\'

GuiCreate("Würfel Generator", 338, 216,(@DesktopWidth-338)/2, (@DesktopHeight-216)/2 ,  BitOR($WS_VISIBLE, $WS_CAPTION, $WS_SYSMENU, $WS_POPUP, $WS_CLIPSIBLINGS) )

$shake = GuiCtrlCreateButton("Shake", 130, 160, 80, 30)
$Pic_1 = GuiCtrlCreatePic($location & "Würfel1.jpg", 30, 40, 60, 60)
$Pic_2 = GuiCtrlCreatePic($location & "Würfel1.jpg", 140, 40, 60, 60)
$Pic_3 = GuiCtrlCreatePic($location & "Würfel2.jpg", 250, 40, 60, 60)

GuiSetState()
While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    case $msg = $shake
        shake3()
        GUICtrlSetImage($pic_1, $location & "Würfel" & $res1 & ".jpg")
        GUICtrlSetImage($pic_2, $location & "Würfel" & $res2 & ".jpg")
        GUICtrlSetImage($pic_3, $location & "Würfel" & $res3 & ".jpg")
        Sleep(10)
    EndSelect
Sleep(30)
WEnd
Exit

Func shake1()
    $res1 = Random(1,6,1)
EndFunc 

Func shake2()
    $res1 = Random(1,6,1)
    $res2 = Random(1,6,1)
EndFunc

Func shake3()
    $res1 = Random(1,6,1)
    $res2 = Random(1,6,1)
    $res3 = Random(1,6,1)
EndFunc
Edited by SmOke_N

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

@Jdeb, Did you BitOr() them (

Yes, first thing i tried but didn't help...

Thx for the Help JdeB. :lmao:

Works now very fine.

I´m wondering too about it :P

Looks like a Bug in the BETA to me since it works fine with the 3.1.1 production version

@JP any idea what could cause this ???

Edited by JdeB

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Yes, first thing i tried but didn't help...

Looks like a Bug in the BETA to me since it works fine with the 3.1.1 production version

@JP any idea what could cause this ???

Definitlety coming from WS_VISIBLE.

All Createpic that follow are considered as dynamic control creation. The GUISetState do nothing if WS_VISIBLE is used.

I think GUIBuilder must be updated as it is a bad habit to use both. For the time being remove the WS_VISIBLE during I analyse the situation. :P

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