Sign in to follow this  
Followers 0
ahmed9100

help plz

7 posts in this topic

i have a problem like this

\/

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 160, 144, 392, 216)
$1 = GUICtrlCreateButton("Button1", 8, 8, 137, 33, $WS_GROUP)
$1 = GUICtrlCreateButton("Button2", 8, 48, 137, 33, $WS_GROUP)
$1 = GUICtrlCreateButton("Button3", 8, 88, 137, 33, $WS_GROUP)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        case $1
            MsgBox("","","")
    EndSwitch
WEnd

how can i define the first button and the next and the next and if i made it like this

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 160, 144, 392, 216)
GUICtrlCreateButton("Button1", 8, 8, 137, 33, $WS_GROUP)
GUICtrlCreateButton("Button2", 8, 48, 137, 33, $WS_GROUP)
GUICtrlCreateButton("Button3", 8, 88, 137, 33, $WS_GROUP)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        case $1
            MsgBox("","","")
    EndSwitch
WEnd

is there any way to know the button name !

and i know i can rename every button but i need another way

Share this post


Link to post
Share on other sites



Probably via a load of functions including ControlGetText() amongs others and writing a heap of unessesary code to navigate around the correct way.

Ive honestly no Idea why you would wnt to do such a thing, what are you trying to accomplish?


AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites

i making a backup script and here is the code

this code to chose the program and the backup folder option that work good

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GuiButton.au3>
#include <GuiImageList.au3>
#Include <Array.au3>
#include <GuiListView.au3>
#Include <File.au3>
#include <Misc.au3>
$dll = DllOpen("user32.dll")
If Not FileExists("data") Then
    DirCreate("data")
EndIf
#Region ### START Koda GUI section ### Form=c:\users\el-zaeem\desktop\backup\bacckup form.kxf
$Form1_1 = GUICreate("Z - Backup", 607, 560, 230, 132)
$Group1 = GUICtrlCreateGroup("", 8, 8, 585, 201)
$path_source = GUICtrlCreateInput("", 72, 43, 497, 21)
$browes_source = GUICtrlCreateButton("Browse", 16, 40, 49, 25, $WS_GROUP)
$Browes_b_dir = GUICtrlCreateButton("Browse", 17, 131, 49, 25, $WS_GROUP)
$path_b_dir = GUICtrlCreateInput("", 73, 134, 497, 21)
$icon = GUICtrlCreateButton("", 17, 160, 49, 41, $WS_GROUP)
$add = GUICtrlCreateButton("Add", 496, 168, 73, 25, $WS_GROUP)
$folder_to_b = GUICtrlCreateButton("Browse", 17, 86, 49, 25, $WS_GROUP)
$F2p_path = GUICtrlCreateInput("", 73, 89, 497, 21)
$Label3 = GUICtrlCreateLabel("Application dire", 17, 24, 76, 17)
$Label4 = GUICtrlCreateLabel("Folder to backup", 17, 69, 84, 17)
$Label5 = GUICtrlCreateLabel("Backup dir", 16, 114, 55, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group2 = GUICtrlCreateGroup(" Options ", 8, 216, 585, 57)
$Checkbox1 = GUICtrlCreateCheckbox("Start lancher on computer startup", 24, 240, 177, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
Local $iExWindowStyle = BitOR($WS_EX_DLGMODALFRAME, $WS_EX_CLIENTEDGE)
Local $iExListViewStyle = BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES, $LVS_EX_GRIDLINES, $LVS_EX_DOUBLEBUFFER)
$hListView = GUICtrlCreateListView("Application|Source folder|backupfolder|Application source", 8, 304,585, 201,-1,$iExWindowStyle)
_GUICtrlListView_SetColumnWidth($hListView, 0, 180)
_GUICtrlListView_SetColumnWidth($hListView, 1, 200)
_GUICtrlListView_SetColumnWidth($hListView, 2, 200)
_GUICtrlListView_SetColumnWidth($hListView, 3, 200)
$Label1 = GUICtrlCreateLabel("Application  List", 9, 280, 95, 17)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
$ok = GUICtrlCreateButton("ok", 500, 518, 81, 25, $WS_GROUP)
$Delete = GUICtrlCreateButton("Delete", 400, 518, 81, 25, $WS_GROUP)
$list_icon = GUICtrlCreateButton("", 8, 510, 49, 41, $WS_GROUP)
$restore = GUICtrlCreateButton("Restore", 100, 518, 81, 25, $WS_GROUP)
$edit = GUICtrlCreateButton("Edit", 300, 518, 81, 25, $WS_GROUP)
$backup = GUICtrlCreateButton("backup", 200, 518, 81, 25, $WS_GROUP)
$Label2 = GUICtrlCreateLabel("Made by Elzaem", 512, 280, 82, 17)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
    _GUICtrlListView_RegisterSortCallBack($hListView, False)
fill()
$b1 = 0
While 1
    $nMsg = GUIGetMsg()
        If _IsPressed("01", $dll) Then
                $selected = _GUICtrlListView_GetSelectionMark($hListView)
                if $selected = -1 Then
                    Else
                $delto = _GUICtrlListView_GetItemText($hListView, $selected,3)
                $iconfile_to_use = $delto
                $array = StringSplit($iconfile_to_use, '\', 1)
                $name = $array[$array[0]]
                $newname = StringReplace($name,".exe","")
                $hImage = _GUIImageList_Create(32, 32, 5, 3, 6)
                _GUIImageList_AddIcon($hImage, $iconfile_to_use, 0, True)
                _GUICtrlButton_SetImageList($list_icon, $hImage,4)
                EndIf
        EndIf
    Switch $nMsg
        case $browes_source
            $file = FileOpenDialog("Select file", @ProgramFilesDir & "", "Application (*.exe)", 1 + 4 )
            If @error Then
                GUICtrlSetData($path_source,"")
            Else
                $iconfile_to_use = $file
                $array = StringSplit($iconfile_to_use, '\', 1)
                $name = $array[$array[0]]
                $newname = StringReplace($name,".exe","")
                $hImage = _GUIImageList_Create(32, 32, 5, 3, 6)
                _GUIImageList_AddIcon($hImage, $iconfile_to_use, 0, True)
                _GUICtrlButton_SetImageList($icon, $hImage,4)
                GUICtrlSetData($path_source,$file)
            EndIf
        case $folder_to_b
            $var = FileSelectFolder("Choose a folder.", "")
            if $var = "" Then
            GUICtrlSetData($F2p_path,"")
            EndIf
            GUICtrlSetData($F2p_path,$var)
        case $Browes_b_dir
            $var2 = FileSelectFolder("Choose a folder.", "")
            if $var2 = "" Then
                GUICtrlSetData($path_b_dir,"")
            EndIf
            GUICtrlSetData($path_b_dir,$var2)
        case $add
            if $b1 = 0 Then
            if GUICtrlRead($path_source) = "" or GUICtrlRead($F2p_path) = "" or GUICtrlRead($path_b_dir) = "" Then
            MsgBox("Error","Notic","Please choose  backup and restore folders")
            Else
            $array = StringSplit(GUICtrlRead($path_source), '\', 1)
            $name = $array[$array[0]]
            $newname = StringReplace($name,".exe","")
            IniWrite(@ScriptDir & "\data\" & $newname & ".ini","info","name",$name)
            IniWrite(@ScriptDir & "\data\" & $newname & ".ini","info","source",GUICtrlRead($path_source))
            IniWrite(@ScriptDir & "\data\" & $newname & ".ini","info","surcedir",GUICtrlRead($F2p_path))
            IniWrite(@ScriptDir & "\data\" & $newname & ".ini","info","backupdir",GUICtrlRead($path_b_dir))
            _GUICtrlListView_DeleteAllItems($hListView)
            fill()
            EndIf
            EndIf
        Case $hListView
            _GUICtrlListView_SortItems($hListView, GUICtrlGetState($hListView))

        case $Delete
            if $b1 = 0 Then
            $selected = _GUICtrlListView_GetSelectionMark($hListView)
            $delto = _GUICtrlListView_GetItemText($hListView, $selected)
            $newname = StringReplace($delto,".exe",".ini")
            FileDelete(@ScriptDir & "\data\" & $newname)
            _GUICtrlListView_DeleteAllItems($hListView)
            fill()
            EndIf
        case $ok
            Exit
            DllClose($dll)
        Case $GUI_EVENT_CLOSE
            Exit
            DllClose($dll)
        case $edit
                $selected = _GUICtrlListView_GetSelectionMark($hListView)
                if $selected = -1 Then
                Else
                $delto = _GUICtrlListView_GetItemText($hListView, $selected,0)
                $newdata = StringReplace($delto,"exe","ini")
                GUICtrlSetData($path_source,"")
                GUICtrlSetData($F2p_path,"")
                GUICtrlSetData($path_b_dir,"")
                $AP_path = _GUICtrlListView_GetItemText($hListView, $selected,3)
                $sur_path = _GUICtrlListView_GetItemText($hListView, $selected,1)
                $back_path = _GUICtrlListView_GetItemText($hListView, $selected,2)
                GUICtrlSetData($path_source,$AP_path)
                GUICtrlSetData($F2p_path,$sur_path)
                GUICtrlSetData($path_b_dir,$back_path)
                EndIf
    EndSwitch
WEnd
Func fill()
$member=_FileListToArray(@ScriptDir & "\data")
If @Error Then
    MsgBox (0,"","No data Found.")
    Else
$filecount = $member[0]
if $filecount = "0" Then
    Else
    $i = 0
    Do
    $i = $i + 1
        $name1 = IniRead(@ScriptDir & "\data\" &$member[$i] ,"info","name","Error")
        $ip1 = IniRead(@ScriptDir & "\data\" &$member[$i] ,"info","source","Error")
        $phone1 = IniRead(@ScriptDir & "\data\" &$member[$i] ,"info","surcedir","Error")
        $mac1 = IniRead(@ScriptDir & "\data\" &$member[$i] ,"info","backupdir","Error")
        GUICtrlCreateListViewItem($name1 &"|"& $phone1 & "|"& $mac1 & "|" & $ip1, $hListView)
    Until $i = $filecount
EndIf
EndIf
EndFunc

and i have the problem in this code and i dont like to use list so i made this

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GuiImageList.au3>
#include <GuiButton.au3>
#Include <Array.au3>
#Include <File.au3>
$member=_FileListToArray(@ScriptDir & "\data\")
If @Error Then
    MsgBox (0,"","No Application Found.")
Else
$filecount = $member[0]
$hi = 45
$hight = 138
$hig = 0
Do
$hight = $hight + $hi
$hig = $hig + 1
Until $hig = $filecount
$hight = $hight - $hi
$Form1 = GUICreate("Luncher", 175, $hight, 829, 123)
$Group1 = GUICtrlCreateGroup("", 8, 8, 161, 49)
$Label1 = GUICtrlCreateLabel("Select Application", 16, 20, 143, 27)
GUICtrlSetFont(-1, 12, 800, 0, "Comic Sans MS")
GUICtrlSetColor(-1, 0x800000)
GUICtrlCreateGroup("", -99, -99, 1, 1)
if $filecount = "0" Then
Else
$hi1 = 45
$hight1 = 65
$hig1 = 0
Do
$hight1 = $hight1 + $hi1
$hig1 = $hig1 + 1
Until $hig1 = $filecount
$hight1 = $hight1 - $hi1
$Group2 = GUICtrlCreateGroup("", 8, 64, 161, $hight1)
$h5 = 45
$bhight = 80
    $i = 0
    Do
    $i = $i + 1
    $file = IniRead(@ScriptDir & "\data\"  &$member[$i] ,"info","source","Error")
        $iconfile_to_use = $file
        $array = StringSplit($iconfile_to_use, '\', 1)
        $name = $array[$array[0]]
        $newname = StringReplace($name,".exe","")
        $hImage = _GUIImageList_Create(32, 32, 5, 3, 6)
        _GUIImageList_AddIcon($hImage, $iconfile_to_use, 0, True)
        $b = GUICtrlCreateButton($newname, 16, $bhight, 145, 41, $WS_GROUP)
        _GUICtrlButton_SetImageList($b, $hImage)
        $bhight = $bhight + $h5
Until $i = $filecount
EndIf
EndIf
GUISetState(@SW_SHOW)
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        case $b
            MsgBox("","","") ;- here is the problem i dont know what to write  <_< 
    EndSwitch
WEnd

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

thx guys for trying to help i have find a way to do what i want i used array like this

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Array.au3>
Local $avArray[4]
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 160, 144, 392, 216)
$avArray[1] = GUICtrlCreateButton("Button1", 8, 8, 137, 33, $WS_GROUP)
$avArray[2] = GUICtrlCreateButton("Button2", 8, 48, 137, 33, $WS_GROUP)
$avArray[3] = GUICtrlCreateButton("Button3", 8, 88, 137, 33, $WS_GROUP)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $avArray[1]
            MsgBox("","","1")
        Case $avArray[2]
            MsgBox("","","2")
        Case $avArray[3]
            MsgBox("","","3")
    EndSwitch
WEnd

thx again every one

Edited by ahmed9100

Share this post


Link to post
Share on other sites

this is the last code

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GuiImageList.au3>
#include <GuiButton.au3>
#Include <Array.au3>
#Include <File.au3>
$member=_FileListToArray(@ScriptDir & "\data\")
If @Error Then
    MsgBox (0,"","No Application Found.")
    Exit
Else
$filecount = $member[0]
$hi = 45
$hight = 138
$hig = 0
Do
$hight = $hight + $hi
$hig = $hig + 1
Until $hig = $filecount
$hight = $hight - $hi
$Form1 = GUICreate("Luncher", 175, $hight, 829, 123)
$Group1 = GUICtrlCreateGroup("", 8, 8, 161, 49)
$Label1 = GUICtrlCreateLabel("Select Application", 16, 20, 143, 27)
GUICtrlSetFont(-1, 12, 800, 0, "Comic Sans MS")
GUICtrlSetColor(-1, 0x800000)
GUICtrlCreateGroup("", -99, -99, 1, 1)
if $filecount = "0" Then
Else
$hi1 = 45
$hight1 = 65
$hig1 = 0
Do
$hight1 = $hight1 + $hi1
$hig1 = $hig1 + 1
Until $hig1 = $filecount
$hight1 = $hight1 - $hi1
$Group2 = GUICtrlCreateGroup("", 8, 64, 161, $hight1)
$h5 = 45
$bhight = 80
    $i = 0
    Do
    $i = $i + 1
    $file = IniRead(@ScriptDir & "\data\"  &$member[$i] ,"info","source","Error")
        $iconfile_to_use = $file
        $array = StringSplit($iconfile_to_use, '\', 1)
        $name = $array[$array[0]]
        $newname = StringReplace($name,".exe","")
        $hImage = _GUIImageList_Create(32, 32, 5, 3, 6)
        _GUIImageList_AddIcon($hImage, $iconfile_to_use, 0, True)
        $member[$i] = GUICtrlCreateButton($newname, 16, $bhight, 145, 41, $WS_GROUP)
        _GUICtrlButton_SetImageList($member[$i], $hImage)
        $bhight = $bhight + $h5
Until $i = $filecount
EndIf
EndIf
GUISetState(@SW_SHOW)
While 1
    $nMsg = GUIGetMsg()
$i = 0
Do
$i = $i + 1
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
Case $member[$i]
    MsgBox("","",$i)
    EndSwitch
Until $i = $member[0]
WEnd

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