Jump to content

Recommended Posts

Posted (edited)

here is what i have.

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_outfile=..\Test.exe
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include<array.au3>


Opt("GUIOnEventMode", 1)
$Form1 = GUICreate("Form1", 625, 445, 193, 125)
GUISetState(@SW_SHOW)
dim $Button[11]
$g=0
for $x=1 to ubound($Button)-1
$Button[$x] = GUICtrlCreateButton("Butt", 5+$g, 24, 49, 25, 0)
GUICtrlSetOnEvent($Button[$x],"butt")
$g+=55
Next
_ArrayDisplay($Button)
while 1
    sleep(50)
    WEnd


func butt()
    Local $iD = @GUI_CtrlId
    
    for $b=1 to UBound($Button)-1
        if $id=$Button[$b] Then
            ConsoleWrite($iD&" <- id   $button -> "&$b&@Lf)
        EndIf
        Next
    EndFunc

works a treat....... until...... you runn another script with a button in the script.

try it.... run 2 instances of this program.... the 1st instance will work aboviously... but because the 2nd instance now gives out new GUI_ctrlid the 2nd script wont work.

can you think of a workaround.... because i have written serveral secripts and would like them to run and not conflict with each other.

Edited by Aceguy
Posted (edited)

k, sorted it..... just figured out consolwrite cannot share 2 prgrams, thats why my test script wouldnt work.

but have modified it to be more friendly.... cos when i add labels ect to the for next loop it changed everthing.... but works.

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_outfile=..\Test.exe
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include<array.au3>


Opt("GUIOnEventMode", 1)
$Form1 = GUICreate("Form1", 625, 445, 193, 125)
GUISetState(@SW_SHOW)

dim $Button[11]
dim $label[11]

$g=0
for $x=1 to ubound($Button)-1
$Button[$x] = GUICtrlCreateButton("Butt", 5+$g, 24, 49, 25, 0)
GUICtrlSetOnEvent(-1,"butt")


$label[$x]=GUICtrlCreateLabel("lab",5+$g,50,49,25,0)
GUICtrlSetOnEvent(-1,"label")
$g+=55

Next


while 1
    sleep(50)
    WEnd


func butt()
    Local $iD = @GUI_CtrlId
    
    for $b=$button[1] to $button[10]
        if $id=$b Then
            MsgBox(0,"Button",$id&" "&$b,0)
        EndIf
        Next
    EndFunc
    Func label()
        Local $iD = @GUI_CtrlId
    
    for $l=$label[1] to $label[10]
        if $id=$l Then
            MsgBox(0,"Label",$id&" "&$l,0)
        EndIf
        Next
    
        EndFunc

sorry i did loads of testing....( why is it as soon as i post it, the solution comes to me)..

Edited by Aceguy

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
×
×
  • Create New...