PcExpert Posted March 22, 2006 Posted March 22, 2006 Hello, Yesterday I asked here for a script that looks like a wizard with your own info. Now I want to make a button in it. How can I do that? This is the script: #include <GuiConstants.au3> Dim $show = 0, $Child_[11], $children = 10 $Main = GuiCreate("MyGUI", 516, 323, (@DesktopWidth-516)/2, (@DesktopHeight-323)/2) $Button_1 = GuiCtrlCreateButton("&Next >", 335, 290, 80, 25) $Button_2 = GuiCtrlCreateButton("< &Back", 250, 290, 80, 25) $Button_3 = GuiCtrlCreateButton("&Exit", 420, 290, 80, 25) $Button_6 = GuiCtrlCreateButton("", 10, 270, 495, 3, -1, $WS_EX_STATICEDGE) GuiSetState() $Child_[1] = GuiCreate("", 508, 238, 1, 1, BitOr($WS_CHILD,$WS_TABSTOP)+$WS_DLGFRAME ,-1, $main) $Label_1 = GuiCtrlCreateLabel("Child 1", 10, 10, 230, 30) GuiSetState() $Child_[2] = GuiCreate("", 508, 238, 1, 1, BitOr($WS_CHILD,$WS_TABSTOP)+$WS_DLGFRAME ,-1, $main) $Label_1 = GuiCtrlCreateLabel("Child 2.", 20, 20, 290, 30) GuiSetState(@SW_HIDE) $Child_[3] = GuiCreate("", 508, 238, 1, 1, BitOr($WS_CHILD,$WS_TABSTOP)+$WS_DLGFRAME ,-1, $main) $Label_1 = GuiCtrlCreateLabel("Child 3.", 30, 30, 290, 30) GuiSetState(@SW_HIDE) $Child_[4] = GuiCreate("", 508, 238, 1, 1, BitOr($WS_CHILD,$WS_TABSTOP)+$WS_DLGFRAME ,-1, $main) $Label_1 = GuiCtrlCreateLabel("Child 4.", 40, 40, 290, 30) GuiSetState(@SW_HIDE) $Child_[5] = GuiCreate("", 508, 238, 1, 1, BitOr($WS_CHILD,$WS_TABSTOP)+$WS_DLGFRAME ,-1, $main) $Label_1 = GuiCtrlCreateLabel("Child 5.", 50, 50, 290, 30) GuiSetState(@SW_HIDE) $Child_[6] = GuiCreate("", 508, 238, 1, 1, BitOr($WS_CHILD,$WS_TABSTOP)+$WS_DLGFRAME ,-1, $main) $Label_1 = GuiCtrlCreateLabel("Child 6.", 60, 60, 290, 30) GuiSetState(@SW_HIDE) $Child_[7] = GuiCreate("", 508, 238, 1, 1, BitOr($WS_CHILD,$WS_TABSTOP)+$WS_DLGFRAME ,-1, $main) $Label_1 = GuiCtrlCreateLabel("Child 7.", 70, 70, 290, 30) GuiSetState(@SW_HIDE) $Child_[8] = GuiCreate("", 508, 238, 1, 1, BitOr($WS_CHILD,$WS_TABSTOP)+$WS_DLGFRAME ,-1, $main) $Label_1 = GuiCtrlCreateLabel("Child 8.", 80, 80, 290, 30) GuiSetState(@SW_HIDE) $Child_[9] = GuiCreate("", 508, 238, 1, 1, BitOr($WS_CHILD,$WS_TABSTOP)+$WS_DLGFRAME ,-1, $main) $Label_1 = GuiCtrlCreateLabel("Child 9.", 90, 90, 290, 30) GuiSetState(@SW_HIDE) $Child_[10] = GuiCreate("", 508, 238, 1, 1, BitOr($WS_CHILD,$WS_TABSTOP)+$WS_DLGFRAME ,-1, $main) $Label_1 = GuiCtrlCreateLabel("Child 10..... You Must be Nuts if you have ... 10 Children!!!", 50, 100, 390, 30) GUICtrlSetFont(-1, 10, 650) GuiSetState(@SW_HIDE) While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Or $msg = $Button_3 ExitLoop Case $msg = $Button_1 Set_Next() Case $msg = $Button_2 Set_Back() ;;; EndSelect WEnd ;--------- Functions ------------------- Func Set_Next() For $x = 1 to $children -1 $Nwin = WinGetState( $child_[$x] ) If $Nwin > 5 Then GuiSetState( @SW_HIDE, $child_[$x]) GuiSetState( @SW_SHOW, $child_[$x +1]) Return EndIf Next EndFunc Func Set_Back() For $x = $children To 1 Step -1 $Nwin = WinGetState( $child_[$x] ) If $Nwin > 5 Then GuiSetState( @SW_HIDE, $child_[$x]) GuiSetState( @SW_SHOW, $child_[$x -1]) Return EndIf Next EndFunc For example you click the button then notepad.exe will run Thanks, PcExpert
cdkid Posted March 22, 2006 Posted March 22, 2006 GuiCreate("MyGui") $btn = GuiCtrlCreateButton("abutton",-1, -1) GuiSetState() While 1 sleep(10) $msg = GuiGetMsg() If $msg = $btn Then run("Notepad.exe") endif WEnd That should help you out a little bit AutoIt Console written in C#. Write au3 code right at the console :D_FileWriteToLineWrite to a specific line in a file.My UDF Libraries: MySQL UDF Library version 1.6 MySQL Database UDF's for AutoItI have stopped updating the MySQL thread above, all future updates will be on my SVN. The svn location is:kan2.sytes.net/publicsvn/mysqlnote: This will still be available, but due to my new job, and school hours, am no longer developing this udf.My business: www.hirethebrain.com Hire The Brain HireTheBrain.com Computer Consulting, Design, Assembly and RepairOh no! I've commited Scriptocide!
BigDod Posted March 22, 2006 Posted March 22, 2006 Hello, Yesterday I asked here for a script that looks like a wizard with your own info. Now I want to make a button in it. How can I do that? This is the script: For example you click the button then notepad.exe will run Thanks, PcExpert Here you go, a button on child 6 expandcollapse popup#include <GuiConstants.au3> Dim $show = 0, $Child_[11], $children = 10 $Main = GuiCreate("MyGUI", 516, 323, (@DesktopWidth-516)/2, (@DesktopHeight-323)/2) $Button_1 = GuiCtrlCreateButton("&Next >", 335, 290, 80, 25) $Button_2 = GuiCtrlCreateButton("< &Back", 250, 290, 80, 25) $Button_3 = GuiCtrlCreateButton("&Exit", 420, 290, 80, 25) $Button_6 = GuiCtrlCreateButton("", 10, 270, 495, 3, -1, $WS_EX_STATICEDGE) GuiSetState() $Child_[1] = GuiCreate("", 508, 238, 1, 1, BitOr($WS_CHILD,$WS_TABSTOP)+$WS_DLGFRAME ,-1, $main) $Label_1 = GuiCtrlCreateLabel("Child 1", 10, 10, 230, 30) GuiSetState() $Child_[2] = GuiCreate("", 508, 238, 1, 1, BitOr($WS_CHILD,$WS_TABSTOP)+$WS_DLGFRAME ,-1, $main) $Label_1 = GuiCtrlCreateLabel("Child 2.", 20, 20, 290, 30) GuiSetState(@SW_HIDE) $Child_[3] = GuiCreate("", 508, 238, 1, 1, BitOr($WS_CHILD,$WS_TABSTOP)+$WS_DLGFRAME ,-1, $main) $Label_1 = GuiCtrlCreateLabel("Child 3.", 30, 30, 290, 30) GuiSetState(@SW_HIDE) $Child_[4] = GuiCreate("", 508, 238, 1, 1, BitOr($WS_CHILD,$WS_TABSTOP)+$WS_DLGFRAME ,-1, $main) $Label_1 = GuiCtrlCreateLabel("Child 4.", 40, 40, 290, 30) GuiSetState(@SW_HIDE) $Child_[5] = GuiCreate("", 508, 238, 1, 1, BitOr($WS_CHILD,$WS_TABSTOP)+$WS_DLGFRAME ,-1, $main) $Label_1 = GuiCtrlCreateLabel("Child 5.", 50, 50, 290, 30) GuiSetState(@SW_HIDE) $Child_[6] = GuiCreate("", 508, 238, 1, 1, BitOr($WS_CHILD,$WS_TABSTOP)+$WS_DLGFRAME ,-1, $main) $Label_1 = GuiCtrlCreateLabel("Child 6.", 60, 60, 290, 30) $Button_7 = GUICtrlCreateButton ("Run Notepad", 10, 30, 100) GuiSetState(@SW_HIDE) $Child_[7] = GuiCreate("", 508, 238, 1, 1, BitOr($WS_CHILD,$WS_TABSTOP)+$WS_DLGFRAME ,-1, $main) $Label_1 = GuiCtrlCreateLabel("Child 7.", 70, 70, 290, 30) GuiSetState(@SW_HIDE) $Child_[8] = GuiCreate("", 508, 238, 1, 1, BitOr($WS_CHILD,$WS_TABSTOP)+$WS_DLGFRAME ,-1, $main) $Label_1 = GuiCtrlCreateLabel("Child 8.", 80, 80, 290, 30) GuiSetState(@SW_HIDE) $Child_[9] = GuiCreate("", 508, 238, 1, 1, BitOr($WS_CHILD,$WS_TABSTOP)+$WS_DLGFRAME ,-1, $main) $Label_1 = GuiCtrlCreateLabel("Child 9.", 90, 90, 290, 30) GuiSetState(@SW_HIDE) $Child_[10] = GuiCreate("", 508, 238, 1, 1, BitOr($WS_CHILD,$WS_TABSTOP)+$WS_DLGFRAME ,-1, $main) $Label_1 = GuiCtrlCreateLabel("Child 10..... You Must be Nuts if you have ... 10 Children!!!", 50, 100, 390, 30) GUICtrlSetFont(-1, 10, 650) GuiSetState(@SW_HIDE) While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Or $msg = $Button_3 ExitLoop Case $msg = $Button_1 Set_Next() Case $msg = $Button_2 Set_Back() Case $msg = $Button_7 Run('Notepad.exe') ; Will Run/Open Notepad ;;; EndSelect WEnd ;--------- Functions ------------------- Func Set_Next() For $x = 1 to $children -1 $Nwin = WinGetState( $child_[$x] ) If $Nwin > 5 Then GuiSetState( @SW_HIDE, $child_[$x]) GuiSetState( @SW_SHOW, $child_[$x +1]) Return EndIf Next EndFunc Func Set_Back() For $x = $children To 1 Step -1 $Nwin = WinGetState( $child_[$x] ) If $Nwin > 5 Then GuiSetState( @SW_HIDE, $child_[$x]) GuiSetState( @SW_SHOW, $child_[$x -1]) Return EndIf Next EndFunc Time you enjoyed wasting is not wasted time ......T.S. Elliot Suspense is worse than disappointment................Robert Burns God help the man who won't help himself, because no-one else will...........My Grandmother
PcExpert Posted March 23, 2006 Author Posted March 23, 2006 (edited) thanks, but how to put a button on each child of the wizard. I tried something, this is my code: #include <GuiConstants.au3> Dim $show = 0, $Child_[11], $children = 10 $Main = GuiCreate("MyGUI", 516, 323, (@DesktopWidth-516)/2, (@DesktopHeight-323)/2) $Button_1 = GuiCtrlCreateButton("&Next >", 335, 290, 80, 25) $Button_2 = GuiCtrlCreateButton("< &Back", 250, 290, 80, 25) $Button_3 = GuiCtrlCreateButton("&Exit", 420, 290, 80, 25) $Button_6 = GuiCtrlCreateButton("", 10, 270, 495, 3, -1, $WS_EX_STATICEDGE) GuiSetState() $Child_[1] = GuiCreate("", 508, 238, 1, 1, BitOr($WS_CHILD,$WS_TABSTOP)+$WS_DLGFRAME ,-1, $main) $Label_1 = GuiCtrlCreateLabel("Child 1", 10, 10, 230, 30) GuiSetState() $Child_[2] = GuiCreate("", 508, 238, 1, 1, BitOr($WS_CHILD,$WS_TABSTOP)+$WS_DLGFRAME ,-1, $main) $Label_1 = GuiCtrlCreateLabel("Child 2.", 20, 20, 290, 30) GuiSetState(@SW_HIDE) $Child_[3] = GuiCreate("", 508, 238, 1, 1, BitOr($WS_CHILD,$WS_TABSTOP)+$WS_DLGFRAME ,-1, $main) $Label_1 = GuiCtrlCreateLabel("Child 3.", 30, 30, 290, 30) GuiSetState(@SW_HIDE) $Child_[4] = GuiCreate("", 508, 238, 1, 1, BitOr($WS_CHILD,$WS_TABSTOP)+$WS_DLGFRAME ,-1, $main) $Label_1 = GuiCtrlCreateLabel("Child 4.", 40, 40, 290, 30) GuiSetState(@SW_HIDE) $Child_[5] = GuiCreate("", 508, 238, 1, 1, BitOr($WS_CHILD,$WS_TABSTOP)+$WS_DLGFRAME ,-1, $main) $Label_1 = GuiCtrlCreateLabel("Child 5.", 50, 50, 290, 30) GuiSetState(@SW_HIDE) $Child_[6] = GuiCreate("", 508, 238, 1, 1, BitOr($WS_CHILD,$WS_TABSTOP)+$WS_DLGFRAME ,-1, $main) $Label_1 = GuiCtrlCreateLabel("Child 6.", 60, 60, 290, 30) $Button_7 = GUICtrlCreateButton ("Run Notepad", 10, 30, 100) GuiSetState(@SW_HIDE) $Child_[7] = GuiCreate("", 508, 238, 1, 1, BitOr($WS_CHILD,$WS_TABSTOP)+$WS_DLGFRAME ,-1, $main) $Label_1 = GuiCtrlCreateLabel("Child 7.", 70, 70, 290, 30) $Button_8 = GUICtrlCreateButton ("Run Notepad", 10, 30, 100) GuiSetState(@SW_HIDE) $Child_[8] = GuiCreate("", 508, 238, 1, 1, BitOr($WS_CHILD,$WS_TABSTOP)+$WS_DLGFRAME ,-1, $main) $Label_1 = GuiCtrlCreateLabel("Child 8.", 80, 80, 290, 30) GuiSetState(@SW_HIDE) $Child_[9] = GuiCreate("", 508, 238, 1, 1, BitOr($WS_CHILD,$WS_TABSTOP)+$WS_DLGFRAME ,-1, $main) $Label_1 = GuiCtrlCreateLabel("Child 9.", 90, 90, 290, 30) GuiSetState(@SW_HIDE) $Child_[10] = GuiCreate("", 508, 238, 1, 1, BitOr($WS_CHILD,$WS_TABSTOP)+$WS_DLGFRAME ,-1, $main) $Label_1 = GuiCtrlCreateLabel("Child 10..... You Must be Nuts if you have ... 10 Children!!!", 50, 100, 390, 30) GUICtrlSetFont(-1, 10, 650) GuiSetState(@SW_HIDE) While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Or $msg = $Button_3 ExitLoop Case $msg = $Button_1 Set_Next() Case $msg = $Button_2 Set_Back() Case $msg = $Button_7 Run('Notepad.exe') ; Will Run/Open Notepad Case $msg = $Button_8 Run('/examples/1.exe') ; Will Run/Open Notepad ;;; EndSelect WEnd ;--------- Functions ------------------- Func Set_Next() For $x = 1 to $children -1 $Nwin = WinGetState( $child_[$x] ) If $Nwin > 5 Then GuiSetState( @SW_HIDE, $child_[$x]) GuiSetState( @SW_SHOW, $child_[$x +1]) Return EndIf Next EndFunc Func Set_Back() For $x = $children To 1 Step -1 $Nwin = WinGetState( $child_[$x] ) If $Nwin > 5 Then GuiSetState( @SW_HIDE, $child_[$x]) GuiSetState( @SW_SHOW, $child_[$x -1]) Return EndIf Next EndFunc There's an othe button at child 7 Thanks, PcExpert Edited March 23, 2006 by PcExpert
Moderators SmOke_N Posted March 23, 2006 Moderators Posted March 23, 2006 (edited) This is not giving you the answer "Directly", but it may in fact give you some ideas on what/how to do things... But it will force you to look at what everything is doing if you want to use the functionalityexpandcollapse popup#include <GuiConstants.au3> Dim $show = 0, $Child[11], $children = 10, $Label[11], $Button[14], $ChildCount = 1 Dim $RunInfo[14] $RunInfo[5] = 'Notepad.exe' $RunInfo[6] = '/examples/1.exe' $RunInfo[7] = 'whatever.exe' $RunInfo[8] = 'whatever2.exe' $RunInfo[9] = 'whatever3.exe' $RunInfo[10] = 'whatever4.exe' $RunInfo[11] = 'whatever5.exe' $RunInfo[12] = 'whatever6.exe' $RunInfo[13] = 'whatever7.exe' $Main = GUICreate("MyGUI", 516, 323, (@DesktopWidth-516)/2, (@DesktopHeight-323)/2) $Button[1] = GUICtrlCreateButton("&Next >", 335, 290, 80, 25) $Button[2] = GUICtrlCreateButton("< &Back", 250, 290, 80, 25) $Button[3] = GUICtrlCreateButton("&Exit", 420, 290, 80, 25) $Button[4] = GUICtrlCreateButton("", 10, 270, 495, 3, -1, $WS_EX_STATICEDGE) For $x = 1 To 9 $Child[$x] = GUICreate("Child" & $x - 1, 508, 238, 1, 1, BitOR($WS_CHILD,$WS_TABSTOP)+$WS_DLGFRAME ,-1, $Main) $Label[$x] = GUICtrlCreateLabel("Child " & $x & ".", $x * 10, $x * 10, 290, 30) $Button[$x + 4] = GUICtrlCreateButton($RunInfo[$x + 4], $x * 10, ($x * 10) + 20, 100) Next $Child[10] = GUICreate("", 508, 238, 1, 1, BitOR($WS_CHILD,$WS_TABSTOP)+$WS_DLGFRAME ,-1, $Main) $Label[10] = GUICtrlCreateLabel("Child 10..... You Must be Nuts if you have ... 10 Children!!!", 50, 100, 390, 30) GUICtrlSetFont(-1, 10, 650) For $i = 2 To 9 GUISetState(@SW_HIDE, $Child[$i]) Next GUISetState(@SW_SHOW, $Main) GUISetState(@SW_SHOW, $Child[1]) While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Or $msg = $Button[3] ExitLoop Case $msg = $Button[1] Set_Next () Case $msg = $Button[2] Set_Back () EndSelect For $x = 5 To 9 If $msg = $Button[$x] Then Run($RunInfo[$x]) EndIf Next WEnd ;--------- Functions ------------------- Func Set_Next() If $ChildCount < 10 Then GUISetState(@SW_HIDE, $Child[$ChildCount]) GUISetState(@SW_SHOW, $Child[$ChildCount + 1]) $ChildCount = $ChildCount + 1 EndIf EndFunc ;==>Set_Next Func Set_Back () If $ChildCount > 1 Then GUISetState(@SW_HIDE, $Child[$ChildCount]) GUISetState(@SW_SHOW, $Child[$ChildCount - 1]) $ChildCount = $ChildCount - 1 EndIf EndFunc ;==>Set_BackEdit: Changed your 2 functions (Set_Next()/Set_Back) you didn't really need the For/Next Loops there. Now it will be a tad faster. Edited March 23, 2006 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.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now