Jump to content

GUI Design?


dufran3
 Share

Recommended Posts

Also, I found the function "GUICtrlSetImage' to set an image on a button, but it just puts the image on the face of a button. Can I set a picture to be a button? Like this button?

Posted Image

Edited by dufran3
Link to comment
Share on other sites

  • Replies 111
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Posted Images

Dim $RunScripts = IniReadSection($ARConfigfile, "ScriptRunner")


Local $nLeft = 200, $nTop = 155, $nWidth = 150, $nHeight = 20

If @error Then 
    MsgBox(4096, "", "Error occurred, probably no INI file.")
Else
    For $i = 1 To $RunScripts[0][0]
        $RunScripts[$i][0] = GUICtrlCreateCheckbox('', $nLeft, $nTop, 20, 20);-1, 0, -1, -1)
        GUICtrlSetColor(-1,0xFFFFFF)
        GUICtrlSetBkColor(-1, 0xFFFFFF)
        $RunScripts[$i][1] = GUICtrlCreateLabel($RunScripts[$i][1], $nLeft + 20, $nTop + 3, $nWidth, $nHeight)
        GUICtrlSetColor(-1,0x000000)
        GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
        $nTop += 22 ; 20, 25 ??? any spacing you want
        
    Next
EndIf

@Valuater

I have been able to get this working but is there a way to split it into as many columns as I want when each column has reached so many chkboxes? I haven't been able to figure out how to do this without duplicating the code numerous time and I'm sure there is a better way. Thanks

EndFuncAutoIt is the shiznit. I love it.
Link to comment
Share on other sites

Dim $RunScripts = IniReadSection($ARConfigfile, "ScriptRunner")


Local $nLeft = 200, $nTop = 155, $nWidth = 150, $nHeight = 20

If @error Then 
    MsgBox(4096, "", "Error occurred, probably no INI file.")
Else
    For $i = 1 To $RunScripts[0][0]
        $RunScripts[$i][0] = GUICtrlCreateCheckbox('', $nLeft, $nTop, 20, 20);-1, 0, -1, -1)
        GUICtrlSetColor(-1,0xFFFFFF)
        GUICtrlSetBkColor(-1, 0xFFFFFF)
        $RunScripts[$i][1] = GUICtrlCreateLabel($RunScripts[$i][1], $nLeft + 20, $nTop + 3, $nWidth, $nHeight)
        GUICtrlSetColor(-1,0x000000)
        GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
        $nTop += 22 ; 20, 25 ??? any spacing you want
        
    Next
EndIfoÝ÷ ÙV¥¹«^¬Z½æÞzvëhëm+0¢¹"î¶+-êÞk²¶)+b¶)í¡«&j|¢[¦Æ¬#§·^æÊ%ºiájÊÞiÈ^vÊ&j|FèÅë«Þmmç§i¹^¶âêÞ¢ëa£hvaÌ".µÛ©'¶)ඡקºg«¢ë-gÒ7ök.­ëaz·¢±¦Þ¶×«Á¬©ä³ú®¢×¦k&Þjëh×6

#include <GUIConstants.au3>


GUICreate("My GUI", 550, 400)  ; will create a dialog box that when displayed is centered

Dim $RunScripts[13][3] = [ _
                ['Appointments Pro OPR','InstallApptsProOPR()','0'], _
                ['Appointments Pro OPSS','InstallApptsProOPSS()','0'], _
                ['Care Manager ' & "test",'InstallCareManager()','0'], _
                ['ds.Pathfinder','InstalldsPathfinder()','0'], _
                ['HES','InstallHES()','0'], _
                ['HPF Workstation','InstallHPF()','0'], _
                ['LaserArc','_LaserArcInstall()','0'], _
                ['ReDoc','_InstallRedoc()','0'], _
                ['ReportXpress','InstallReportXpress()','0'], _
                ['Softmed','_SSIinstall()','0'], _
                ['Star Navigator ' & "tset again",'InstallStar()','0'], _
                ['Tsystem (Laptop)','InstallTsystemLaptop()','0'], _
                ['Tsystem (PC)','InstallTsystemPC()','0'] _
            ]


;Dim $RunScripts = IniReadSection($ARConfigfile, "ScriptRunner")


Local $nLeft = 20, $nTop = 155, $nWidth = 150, $nHeight = 20

Local $colum = 5


    For $i = 1 To UBound($RunScripts) -1
        $RunScripts[$i][0] = GUICtrlCreateCheckbox('', $nLeft, $nTop, 20, 20);-1, 0, -1, -1)
        GUICtrlSetColor(-1,0xFFFFFF)
        GUICtrlSetBkColor(-1, 0xFFFFFF)
        $RunScripts[$i][1] = GUICtrlCreateLabel($RunScripts[$i][1], $nLeft + 20, $nTop + 3, $nWidth, $nHeight)
        GUICtrlSetColor(-1,0x000000)
        GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
        $nTop += 22 ; 20, 25 ??? any spacing you want
       If $i = $colum Then 
           $colum += $colum
           $nLeft += $nWidth + 20
           $nTop = 155
        EndIf
    Next

GUISetState()       ; will display an  dialog box with 1 checkbox

; Run the GUI until the dialog is closed
While 1
    $msg = GUIGetMsg()

    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
WEnd

8)

NEWHeader1.png

Link to comment
Share on other sites

maybe..

#include <GUIConstants.au3>
GUICreate("My GUI", 550, 400)  ; will create a dialog box that when displayed is centered

Dim $RunScripts[13][3] = [ _
                ['Appointments Pro OPR','InstallApptsProOPR()','0'], _
                ['Appointments Pro OPSS','InstallApptsProOPSS()','0'], _
                ['Care Manager ' & "test",'InstallCareManager()','0'], _
                ['ds.Pathfinder','InstalldsPathfinder()','0'], _
                ['HES','InstallHES()','0'], _
                ['HPF Workstation','InstallHPF()','0'], _
                ['LaserArc','_LaserArcInstall()','0'], _
                ['ReDoc','_InstallRedoc()','0'], _
                ['ReportXpress','InstallReportXpress()','0'], _
                ['Softmed','_SSIinstall()','0'], _
                ['Star Navigator ' & "tset again",'InstallStar()','0'], _
                ['Tsystem (Laptop)','InstallTsystemLaptop()','0'], _
                ['Tsystem (PC)','InstallTsystemPC()','0'] _
            ]
;Dim $RunScripts = IniReadSection($ARConfigfile, "ScriptRunner")
Local $nLeft = 20, $nTop = 155, $nWidth = 150, $nHeight = 20

Local $colum = 5
    For $i = 1 To UBound($RunScripts) -1
        $RunScripts[$i][0] = GUICtrlCreateCheckbox('', $nLeft, $nTop, 20, 20);-1, 0, -1, -1)
        GUICtrlSetColor(-1,0xFFFFFF)
        GUICtrlSetBkColor(-1, 0xFFFFFF)
        $RunScripts[$i][1] = GUICtrlCreateLabel($RunScripts[$i][1], $nLeft + 20, $nTop + 3, $nWidth, $nHeight)
        GUICtrlSetColor(-1,0x000000)
        GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
        $nTop += 22 ; 20, 25 ??? any spacing you want
       If $i = $colum Then 
           $colum += $colum
           $nLeft += $nWidth + 20
           $nTop = 155
        EndIf
    Next

GUISetState()       ; will display an  dialog box with 1 checkbox

; Run the GUI until the dialog is closed
While 1
    $msg = GUIGetMsg()

    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
WEnd

8)

Hey thanks for that. What I see is it looks like you put functions in the array? When I run the sample it puts the funtions as the label instead of the actual title of the app, not quite sure how to fix but what i've tried is working. :whistle: Also do you think this can also work with reading from the ini file?

Edit:

Ok, sorry it seems to work great with the ini file for adding the chkbxs that is. THANK YOU!

Now one thing I am foggy on is how to incorporate the above code with actually running the function/programs. I want to be able to read the ini file not only for the dynamic creation of the chckbxs(thanks) but also to get the location of the installs etc. I don't really want to have to update the code unless I make a major design change or something. I looked at

http://www.autoitscript.com/forum/index.ph...st&p=315460 that you posted and not quite sure how to get that intergrated with the above code and then how the Programs[x] functions work. If you have any resources that help me more understand this that would awesome. Thanks

Edited by EndFunc
EndFuncAutoIt is the shiznit. I love it.
Link to comment
Share on other sites

Sorry, If you mentioned _ButtonHover previously, I don't remember it. I looked at it, and it is fantastic, just have to research executing functions on button press. Will have to look through your demo, thx!

Right here

http://www.autoitscript.com/forum/index.ph...st&p=316462

it will do the trick, remember to keep the GUIGetMsg() / MouseOver() in the order indicated in the demo

8)

NEWHeader1.png

Link to comment
Share on other sites

Hey thanks for that.... W

Edit:

Ok, sorry it seems to work great with the ini file for adding the chkbxs that is. THANK YOU!

Welcome!

Now one thing I am foggy on is how to incorporate the above code with actually running the function/programs. I want to be able to read the ini file not only for the dynamic creation of the chckbxs(thanks) but also to get the location of the installs etc. I don't really want to have to update the code unless I make a major design change or something. I looked at

http://www.autoitscript.com/forum/index.ph...st&p=315460 that you posted and not quite sure how to get that intergrated with the above code and then how the Programs[x] functions work. If you have any resources that help me more understand this that would awesome. Thanks

That is the page with the most helpful "direction" for your needs, obviously I cannot write script for you to use in your program without me reading/understanding everything in your program...

I have no desire to do that, and you wont learn that way...

I do believe I have given you the tools you need to make this all operate on a dynamic scale..

you need to do some homework/studying for yourself

... and good luck, i know its a little tough at first

8)

Edited by Valuater

NEWHeader1.png

Link to comment
Share on other sites

Welcome!

That is the page with the most helpful "direction" for your needs, obviously I cannot write script for you to use in your program without me reading/understanding everything in your program...

I have no desire to do that, and you wont learn that way...

I do believe I have given you the tools you need to make this all operate on a dynamic scale..

you need to do some homework/studying for yourself

... and good luck, i know its a little tough at first

8)

Yeah, that's cool. I just didn't know if there was something other than the wiki for examples and things. I do alot of research to try to figure everything that I find out. I don't want it created for me thats why I asked for any resources/websites or other places that was helpful in getting a grasp at the more complicated side of things. Thanks, everything so far as been a great help!

EndFuncAutoIt is the shiznit. I love it.
Link to comment
Share on other sites

Yeah, that's cool. I just didn't know if there was something other than the wiki for examples and things. I do alot of research to try to figure everything that I find out. I don't want it created for me thats why I asked for any resources/websites or other places that was helpful in getting a grasp at the more complicated side of things. Thanks, everything so far as been a great help!

$AppTab = GUICtrlCreateTab(192, 88, 593, 441)
$AppTab1 = GUICtrlCreateTabItem("Software Installations")
$RunInstalls = GUICtrlCreateButton("Run Installs", 24, 479, 137, 25, 0)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")

Dim $InstallPrograms = IniReadSection($ARConfigfile, "Installs")
Local $aInstallTmp
Local $nLeft = 200, $nTop = 155, $nWidth = 150, $nHeight = 20
Local $columns = 10
Local $RadioStatus
Local $Path
If @error Then 
    MsgBox(4096, "", "Error occurred, probably no INI file.")
Else
    For $i = 1 To $InstallPrograms[0][0]
        $aInstallTmp = StringSplit($InstallPrograms[$i][1], "|")
        $Radio1 = GUICtrlCreateRadio('', $nLeft, $nTop, 20, 20);-1, 0, -1, -1)
        GUICtrlSetColor(-1,0xFFFFFF)
        GUICtrlSetBkColor(-1, 0xFFFFFF)
        GUICtrlCreateLabel($aInstallTmp[1], $nLeft + 20, $nTop + 3, $nWidth, $nHeight)
        GUICtrlSetColor(-1,0x000000)
        GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
        GUICtrlSetTip(-1, $aInstallTmp[2])
        $Path = $aInstallTmp[3]
        $nTop += 22 ; 20, 25 ??? any spacing you want
         If $i = $columns Then 
           $columns += $columns
           $nLeft += $nWidth + 20
           $nTop = 155
       EndIf
            
    Next
EndIf
While 1
       $nMsg = GUIGetMsg()
Switch $nMsg
     Case $GUI_EVENT_CLOSE
          Exit
      Case $RunInstalls
         If GuiCtrlRead($Radio1) = 1 Then
         LaunchInstall()
         Endif
EndSwitch
Wend

Func LaunchInstall()
MsgBox(0,0, $Path)
EndFunc

For some reason I can't get it to read the check box and run what I want. Everything seems to work now the way I have except getting it to actually execute whats in the path. The path is $aInstallTmp[3] because I'm reading from the IniFile. What am I doing wrong??

Edited by EndFunc
EndFuncAutoIt is the shiznit. I love it.
Link to comment
Share on other sites

Its like the same routine over and over here, I want to help...

but you both don't follow what i have given you

For $i = 1 To $InstallPrograms[0][0]

$aInstallTmp = StringSplit($InstallPrograms[$i][1], "|")

$Radio1 = GUICtrlCreateRadio('', $nLeft, $nTop, 20, 20);-1, 0, -1, -1)

will create the same $Radio1 over and over and over again, thats why you cant read the one you want

I showed you this

For $x = 1 To $Programs[0]

$ProgCtrl[$x] = GUICtrlCreateCheckbox('', $nLeft, $nTop, 20, 20);-1, 0, -1, -1)

$XSkinID[$x] = GUICtrlCreateLabel($Programs[$x], $nLeft + 20, $nTop + 3, $nWidth, $nHeight)

$nTop += 22 ; 20, 25 ??? any spacing you want

Next

and to read them like this..,.

For $x = 1 To $Programs[0]

If gui control read "check box" = $GUI_CHECKED Then

If FileExists($Programs[$x] Then

RunWait($Programs[$x]

Else

; do what you want... msgbox or ??? Call($Programs[$x])... or ???

EndIf

EndIf

Next

8)

NEWHeader1.png

Link to comment
Share on other sites

Its like the same routine over and over here, I want to help...

but you both don't follow what i have given you

For $i = 1 To $InstallPrograms[0][0]

$aInstallTmp = StringSplit($InstallPrograms[$i][1], "|")

$Radio1 = GUICtrlCreateRadio('', $nLeft, $nTop, 20, 20);-1, 0, -1, -1)

will create the same $Radio1 over and over and over again, thats why you cant read the one you want

I showed you this

For $x = 1 To $Programs[0]

$ProgCtrl[$x] = GUICtrlCreateCheckbox('', $nLeft, $nTop, 20, 20);-1, 0, -1, -1)

$XSkinID[$x] = GUICtrlCreateLabel($Programs[$x], $nLeft + 20, $nTop + 3, $nWidth, $nHeight)

$nTop += 22 ; 20, 25 ??? any spacing you want

Next

and to read them like this..,.

For $x = 1 To $Programs[0]

If gui control read "check box" = $GUI_CHECKED Then

If FileExists($Programs[$x] Then

RunWait($Programs[$x]

Else

; do what you want... msgbox or ??? Call($Programs[$x])... or ???

EndIf

EndIf

Next

8)

I know you're trying to help and thank you, however i've tried this and I can't get it to work inside of my Case statements. The part I want to use to read the checkbox and then execute the command will not work if set to a button for a Case statement. It will give an error like $Programs possible used before being declared even though its in the for/loop several lines above in the code. That's were I am having the difficulty. I have buttons to execute everything and I can't make that happen. Any light?

Edit:

See I also have it split in the file into 3 sections. So Key=Label|ControlTip|Path using the | as a delimiter. I don't know if that complicates things but I am trying to call the path once it reads the control. Just can't get it to work in the case statements. If I set a message box in the for/next loop it will message box every path so I know its reading it right. Just need to translate that into hitting a button to activate after reading the control instead of doing on script run.

Edited by EndFunc
EndFuncAutoIt is the shiznit. I love it.
Link to comment
Share on other sites

Its like the same routine over and over here, I want to help...

but you both don't follow what i have given you

For $i = 1 To $InstallPrograms[0][0]

$aInstallTmp = StringSplit($InstallPrograms[$i][1], "|")

$Radio1 = GUICtrlCreateRadio('', $nLeft, $nTop, 20, 20);-1, 0, -1, -1)

will create the same $Radio1 over and over and over again, thats why you cant read the one you want

I showed you this

For $x = 1 To $Programs[0]

$ProgCtrl[$x] = GUICtrlCreateCheckbox('', $nLeft, $nTop, 20, 20);-1, 0, -1, -1)

$XSkinID[$x] = GUICtrlCreateLabel($Programs[$x], $nLeft + 20, $nTop + 3, $nWidth, $nHeight)

$nTop += 22 ; 20, 25 ??? any spacing you want

Next

and to read them like this..,.

For $x = 1 To $Programs[0]

If gui control read "check box" = $GUI_CHECKED Then

If FileExists($Programs[$x] Then

RunWait($Programs[$x]

Else

; do what you want... msgbox or ??? Call($Programs[$x])... or ???

EndIf

EndIf

Next

8)

@Valuater

Ok I got it working!!! :whistle: Holy crap. I took a step back and created a brand new file instead of trying to adjust the one I had. That way I could see exactly how it worked instead of trying to fit it in mine. Once I did that I got it working with all the code you suggested and was able to implement it using my ini files.

THANK YOU THANK YOU, sorry for the frustration.

EndFuncAutoIt is the shiznit. I love it.
Link to comment
Share on other sites

@Valuater

Ok I got it working!!! :whistle: Holy crap. I took a step back and created a brand new file instead of trying to adjust the one I had. That way I could see exactly how it worked instead of trying to fit it in mine. Once I did that I got it working with all the code you suggested and was able to implement it using my ini files.

THANK YOU THANK YOU, sorry for the frustration.

Thats really good news after all these posts!

Congrats!!!.. and Welcome.

8)

NEWHeader1.png

Link to comment
Share on other sites

Not sure if I sure continue this post, or start a new one. Changed the way that I am creating the buttons. Wanted to make it look pretty. Using images, however, when clicking on the buttons, it isn't running the function. I will show you my old method, then what I am doing now.

$install = XSkinButton ('Start', 230, 260, 75, 25, 'Install')
$Sselect = XSkinButton ('Select All', 230, 300, 75, 25, 'SelectAll')
$deselect = XSkinButton ('Deselect All', 230, 345, 75, 25, 'DeselectAll')
$Exit = XSkinButton ( 'Exit', 230, 390, 75, 25, 'Exitier')

;GUI MESSAGE LOOP
GUISetState()
While GUIGetMsg() <> $GUI_EVENT_CLOSE
WEnd

Func Install()
        MsgBox(0,'','Pressed Install')
EndFunc

Func SelectAll()
       MsgBox(0,'','Pressed SelectAll')
EndFunc

Func DeselectAll()
        MsgBox(0,'','Pressed DeselectAll')
EndFunc
oÝ÷ Ù8b²+0¢¹"âàn´³§¶)à¶ëay»­¶ìºÈ§Ø^ªê-¦·­·-ý²Ü¥xÚ0'(u謶¬jëh×6
$install = _HoverButton("Start", 230, 255, 75, 25, 'Install')
$Sselect = _HoverButton('Select All', 230, 300, 75, 25, 'SelectAll_Tab1')
$deselect = _HoverButton('Deselect All', 230, 345, 75, 25, 'DeselectAll_Tab1')
$Exit = _HoverButton('Exit', 230, 390, 75, 25, 'Exitier')
;$Exit = _ButtonHover ('Exit', 230, 390, 75, 25, 'Exitier')


While 1
    ; required
    _CheckHoverAndPressed ($Main)

    $msg = GUIGetMsg()
    Select
        Case $msg = $install
            MsgBox(64, "test", " You pressed Start   ", 3)
        Case $msg = $deselect
            MsgBox(64, "test", " You pressed deselect   ", 3)
        Case $msg = $Sselect
            MsgBox(64, "test", " You pressed select all   ", 3)
        Case $msg = $Exit
            MsgBox(64, "test", " You pressed exit   ", 3)
        
EndSelect
WEnd

I got the while loop from the example code. The images change while "hover" and when I "press" them, but they aren't doing anything. I will eventually need them to execute function that do more stuff, but just wanted to msgbox to test it.

Link to comment
Share on other sites

It just "AMAZES ME" how you two come so close but just don't quite "GET-IT"!

your code

$install = _HoverButton("Start", 230, 255, 75, 25, 'Install')

demo code ( you said you looked at )

$Button_1 = _HoverButton ("Small", 180, 80, 70, 15, $color)

Notice it is color ... not a function name

*************************

if you have "event mode option" on, GUIGetMsg() will not work

... is that the prob... event mode??

8)

NEWHeader1.png

Link to comment
Share on other sites

Sorry, events are confusing to me. I do know that, the current event mode, is the only way I could get the GUI to work the way I was wanting. The suggested code you gave me.

GUICtrlSetOnEvent( $Button1, "do_this")

Where would I put this? When I declare the button? In the While Loop? I'm not sure where I should put that, so it will execute when needed. Sorry again for my noobness!

I think i figured out where to put this. Testing it right now. I will let you know how it goes.

Edited by dufran3
Link to comment
Share on other sites

Quick question when using "GUICtrlSetOnEvent" can you pass the function a variable? Here are the lines I am trying to use.

$progselect = _HoverButton('Select All', 230, 300, 75, 25)
GUICtrlSetOnEvent($progselect, '_SelectAll($progselect)')oÝ÷ ØçÜ¢êìz+]¡ë'ßÛlyëayû§rب«¨µ'¥yË@]7êèÇ¥yËwõ«~éܶ*'mçºÇ¢¶+'ßÛmçîËb¢yÚ謪ê-^rÐ%«¨´w«z+-ëç-jY_ºw-ÓêÞÂ)em멶-i»rêëz{eʯy§îËb¢wè­æÖªê-^rÐ%6Ö«¨¶«¨µ'¥yË@TÚoj®¢×­qf§µçm¡Ê&n)Þا¶_ºw-í«Hr¥v¬²Øb- :©j|¬z{jëh×6Func _SelectAll($ButtonTab)
    Select
        Case $ButtonTab == $Softselect
            For $i = 0 To UBound($SoftCtrl) - 1
                GUICtrlSetState($SoftCtrl[$i], $GUI_CHECKED)
            Next
        Case $ButtonTab == $progselect
            For $i = 0 to UBound($ProgCtrl) - 1
                GUICtrlSetState($ProgCtrl[$i], $GUI_CHECKED)
            Next
    EndSelect
EndFunc
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...