myxomatosii Posted February 23, 2009 Share Posted February 23, 2009 (edited) Hey guys, I am just learning how to make GUI in AutoIt and I figured I would humble myself and just make my progress public as it may help me.Features I want in my GUI.. (I may add more to this list.)0: I want to make a GUI that opens the (current) user's documents folder.1: GUI window to stay around until its closed manually.2: Button to be relatively responsive without killing the processor (of ANY reasonable PC).3: Scale and size of GUI to be fitting to purpose, ie: small.I just started, working my way through errors to get it at least coming up with a GUI box, so I'll continue to post progress as I figure things out.I AM aware of how many things I am missing.. like I said I am just learning.. so I hope you're not laughing too hard. >.<Perhaps if you see some basic necessities I am missing you could point them out, their basic purposes are still confusing to me.I am using Autoit Documentation on the Autoit site to figure all that I have figured out so far.CURRENT CODE: Crashed lol, I forgot to set location of the button... duh.Opt("GUIOnEventMode",1) docgui() Func docgui() Local $msg GUICreate("Document Opener") GUISetState(@SW_SHOW) GUICtrlCreateButton("Open - My Documents") Sleep(200) EndFuncCODE UPDATE 1: Window hangs around forever, size is nicer, still doesn't do anything.. infinite loop.Opt("GUIOnEventMode", 1) docgui() Func docgui() Local $msg GUICreate("DocOpen", 150, 50) GUISetState(@SW_SHOW) GUICtrlCreateButton("Open - My Documents", 20, 20) While 1 Sleep(2000) WEnd EndFunc;==>docgui Edited February 23, 2009 by myxomatosii Link to comment Share on other sites More sharing options...
dantay9 Posted February 23, 2009 Share Posted February 23, 2009 You seem to have the part that opens My Documents already finished. For the button, you could do GUIGetMsg() to see if it has been pressed. To save the processor, you could add a sleep(10) in the loop. GUICreate("Document Opener", @DesktopWidth/3, @DesktopHeight/3) $Button = GUICtrlCreateButton("Open - My Documents", 5, 5, 75, 23) GUISetState(@SW_SHOW) While 1 $msg = GuiGetMsg() If $msg = $Button Then ; place script to open My Documents here Endif Sleep(15) WEnd For the size of the window, you could look up the macro @DesktopWidth and @DesktopHeight and set the size of the window to be a certain percentage of the screen. Link to comment Share on other sites More sharing options...
erik7426 Posted February 23, 2009 Share Posted February 23, 2009 Hey guys, I am just learning how to make GUI in AutoIt and I figured I would humble myself and just make my progress public as it may help me. Features I want in my GUI.. (I may add more to this list.) 0: I want to make a GUI that opens the (current) user's documents folder. 1: GUI window to stay around until its closed manually. 2: Button to be relatively responsive without killing the processor (of ANY reasonable PC). 3: Scale and size of GUI to be fitting to purpose, ie: small. I just started, working my way through errors to get it at least coming up with a GUI box, so I'll continue to post progress as I figure things out. I AM aware of how many things I am missing.. like I said I am just learning.. so I hope you're not laughing too hard. >.< Perhaps if you see some basic necessities I am missing you could point them out, their basic purposes are still confusing to me. I am using Autoit Documentation on the Autoit site to figure all that I have figured out so far. CURRENT CODE: Crashed lol, I forgot to set location of the button... duh. Opt("GUIOnEventMode",1) docgui() Func docgui() Local $msg GUICreate("Document Opener") GUISetState(@SW_SHOW) GUICtrlCreateButton("Open - My Documents") Sleep(200) EndFunc CODE UPDATE 1: Window hangs around forever, size is nicer, still doesn't do anything.. infinite loop. Opt("GUIOnEventMode", 1) docgui() Func docgui() Local $msg GUICreate("DocOpen", 150, 50) GUISetState(@SW_SHOW) GUICtrlCreateButton("Open - My Documents", 20, 20) While 1 Sleep(2000) WEnd EndFunc;==>docgui You have to "watch" for actions within the GUI. Try this: #include <GUIConstantsEx.au3> docgui() Func docgui() Local $msg GUICreate("DocOpen", 150, 50) $button1 = GUICtrlCreateButton("Open - My Documents", 20, 20) GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $button1 ShellExecute(@MyDocumentsDir) EndSelect WEnd EndFunc ;==>docgui Link to comment Share on other sites More sharing options...
myxomatosii Posted February 23, 2009 Author Share Posted February 23, 2009 (edited) You have to "watch" for actions within the GUI. Try this: #include <GUIConstantsEx.au3> docgui() Func docgui() Local $msg GUICreate("DocOpen", 150, 50) $button1 = GUICtrlCreateButton("Open - My Documents", 20, 20) GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $button1 ShellExecute(@MyDocumentsDir) EndSelect WEnd EndFunc;==>docgui Hey thanks everyone, I just finished my first GUI thanks to you guys =) dantay9: thanks for the great ideas on creating proportional windows sizes ~ erik7426: i thought i may have to use the Select/Case loop but honestly i hadn't had any experience with it before so i was unsure of the format, but i think i understand it now. now i've got to come up with something a bit more challenging... and i've got to go read up on the shellexcecute command, had never used that before. i'm sure i'll be posting more questions soon lol, i'm just starting out x,x if you guys don't mind me asking, why is #include so important in GUI scripts? Working Code! #include <GUIConstantsEx.au3> docgui() Func docgui() Local $msg GUICreate("DocOpen", 150, 50) GUISetState(@SW_SHOW) $button1=GUICtrlCreateButton("Open - My Documents",20,20) While 1 $msg=GUIGetMsg() Select Case $msg=$gui_event_close ExitLoop Case $msg=$button1 ShellExecute(@mydocumentsdir) EndSelect Sleep(30) WEnd EndFunc ;==>docgui Edited February 23, 2009 by myxomatosii Link to comment Share on other sites More sharing options...
deus Posted February 24, 2009 Share Posted February 24, 2009 Hi there, My first script looked excact like it, but more buttons : I modified it so I could post it here for you, so you could make your GUI even bigger ; Sorry for my bad english, its just school's english CODE#include <GUIConstantsEx.au3> Opt("MustDeclareVars", 0) examplegui() Func exampleGUI() Local $button_1, $button_2, $button_3, $msg ; you can make more like this way and just put more $button_* in. * = number or text. GUICreate ( "Opener", 111, 111) Opt("GUICoordMode", 2) $button_1 = GUICtrlCreateButton ( "Run SciTE", 7, 10, 100) $button_2 = GUICtrlCreateButton ( "Run Notepad", -1, 10, 100) ; Just 3 examples given to help you on the way. $button_3 = GUICtrlCreateBUtton ( "Exit", -1, 10, 100) GUISetState (@SW_SHOW) While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $button_1 Run ( "C:\Program Files\AutoIt3\SciTE\SciTE.exe" ) Case $msg = $button_2 Run ( "notepad.exe" ) Case $msg = $button_3 MsgBox (0, "Goodbye", "Goodbye", 1) Exit EndSelect WEnd EndFunc ;==> exampleGUI Link to comment Share on other sites More sharing options...
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