Jump to content

Is it AutoIT or a error in my script?


 Share

Recommended Posts

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

Link to comment
Share on other sites

  • Moderators

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.

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.

Link to comment
Share on other sites

  • Developers

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..

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • Moderators

@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

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.

Link to comment
Share on other sites

  • Developers

@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

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
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

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...