LeThanh201 Posted May 28, 2008 Posted May 28, 2008 Hi, all. I want to minimize my GUI automatically when starting with windows, I attempt but I can't. Help me, please !!!!!!!!!!!!! This is my script (Encoding is UTF-8 with BOM (Hic, I am a Vietnamese)) expandcollapse popup#include <GUIConstantsEx.au3> #include <constants.au3> #include <ButtonConstants.au3> #notrayicon opt("TrayMenuMode",1) ;HotKeySet HotKeySet("^+{PgUp}", "hien") Func hien() GUISetState(@SW_SHOW, $chinh) EndFunc HotKeySet("^+{PgDn}", "an") Func an() GUISetState(@SW_HIDE, $chinh) TrayTip("Thông báo", "Chương trình đang chạy"& @CRLF &"Ctrl + Alt + {Xuống} - Đóng/Mở ổ CD-Rom" & @CRLF & "Ctrl + Shift + {PgUp} - Hiện bảng điều khiển" & @CRLF & "Ctrl + Shift + {PgDn} - Ẩn bảng điều khiển"& @CRLF & "Ctrl + Shift + {End} - Thoát", 5, 1) EndFunc HotKeySet("^+{End}", "thoat") Func thoat() $msg = GUIGetMsg() $msg = $gui_event_close EndFunc HotKeySet("^+{down}", "chuyendoi") Func chuyendoi() $msg = GUIGetMsg() $msg = $dm EndFunc ;GUI $chinh = GUICreate("Open/Close CDRom", 310, 230) GUISetBkColor(0x00ff00, $chinh) GUISetIcon('shell32.dll', 295) $label1 = GUICtrlCreateLabel('Open/Close CD-Rom', 37, 10, 280,35) GUICtrlSetFont($label1, 19, 400, 4, "Monotype Corsiva") $dm = GUICtrlCreateButton("Mở", 113, 50, 70, 60) GUICtrlSetFont($dm, 14, 400, -1, "MS Reference Sans Serif") GUICtrlSetBkColor($dm, 0x8080FF) $about = GUICtrlCreateButton("About", 10, 150, 60, 30) GUIctrlSetBkColor($about, 0x00FFFF) ;Menu $label2 = GUICtrlCreateLabel("Sử dụng các phím nóng sau đây :", 80, 120) GUICtrlCreateLabel("Ctrl + Shift + {Xuống} - Đóng/Mở", 80, 135) GUICtrlCreateLabel("Ctrl + Shift + {PgUp} - Hiện bảng điều khiển", 80, 150) GUICtrlCreateLabel("Ctrl + Shift + {PgDn} - Ẩn bảng điều khiển", 80,165) GUICtrlCreateLabel("Ctrl + Shift + {End} - Thoát", 80, 180) $cb1 = GUICtrlCreateCheckbox('&Khởi động cùng StartUp ===>', 10, 195) $ok = GUICtrlCreateButton('OK', 180, 195, 50, 20) GUICtrlSetBkColor($ok, 0x99FF00) $label3 = GUICtrlCreateLabel("Let's", 20, 60, 93, 50) GUICtrlSetFont($label3, 30, 400, 12, "Poor Richard") $label4 = GUICtrlCreateLabel("Go!!!", 203, 60, 93, 50) GUICtrlSetFont($label4, 30, 400, 12, "Poor Richard") $tt = GUICtrlRead($dm) Opt('guicloseonesc', 0) GUISetState(@SW_SHOW, $chinh) ;Drive $drive = DriveGetDrive("CDRom") ;Tray $dk = TrayCreateItem("Bảng điều khiển - Ctrl + Shift + {PgUp}") TrayItemSetState($dk, $tray_default) TrayCreateItem("") $tacgia = TrayCreateItem("Tác giả") TrayCreateItem("") $thoat = TrayCreateItem("Thoát - Ctrl + Shift + {End}") TraySetIcon('shell32.dll', 295) TraySetState() TraySetClick(8) ;Đọc trạng thái StartUp if FileExists(@StartupCommonDir & '\' & @ScriptName) Then GUICtrlSetState($cb1, $gui_checked) Else GUICtrlSetState($cb1, $gui_unchecked) EndIf ;Begin while 1 $msg = GUIGetMsg() $msg1 = TrayGetMsg() Select Case $msg1 = $dk GUISetState(@SW_SHOWNORMAL, $chinh) case $msg = $gui_event_minimize GUISetState(@sw_hide, $chinh) TrayTip("Thông báo", "Chương trình đang chạy"& @CRLF &"Ctrl + Shift + {Xuống} - Đóng/Mở ổ CD-Rom" & @CRLF & "Ctrl + Shift + {PgUp} - Hiện bảng điều khiển" & @CRLF & "Ctrl + Shift + {PgDn} - Ẩn bảng điều khiển"& @CRLF & "Ctrl + Shift + {End} - Thoát", 10, 1) case $msg = $gui_event_close or $msg1 = $thoat Exit case $msg = $dm and $tt = "Mở" CDTray($drive[1], "open") GUICtrlSetData($dm, "Đóng") $tt = GUICtrlRead($dm) case $msg = $dm and $tt = "Đóng" CDTray($drive[1], "closed") GUICtrlSetData($dm, "Mở") $tt = GUICtrlRead($dm) case $msg = $about or $msg1 = $tacgia MsgBox(64, "Lê Văn Thành","Đây là phần mềm giúp các bạn có thể dễ dàng đóng/mở " &@crlf&" ổ CDRom bằng việc sử dụng các phím nóng."&@crlf&" Chúc các bạn vui vẻ !"&@crlf&@crlf&'Tác giả : Lê Văn Thành' &@crlf& 'Lớp 11H, trường THPT Ba Đình - Nga Sơn - Thanh Hoá'&@crlf & 'Email: forget_me_not_please@yahoo.com'&@crlf &' setbody_nth2005@yahoo.com') Case $msg = $ok $ttcb1 = GUICtrlRead($cb1) If $ttcb1 = $gui_checked Then FileCopy(@ScriptFullPath, @StartupCommonDir, 1) MsgBox(64, 'Thông báo', 'Đã kích hoạt khởi động cùng StartUp') ElseIf $ttcb1 = $gui_unchecked Then FileDelete(@StartupCommonDir & '\' & @ScriptName) MsgBox(64, 'Thông báo', 'Đã loại bỏ khởi động cùng StartUp') EndIf EndSelect WEnd
ProgAndy Posted May 28, 2008 Posted May 28, 2008 You should call your Script with a Parameter, when it AutoStarts: script.exe -silent In Script: If $CMDLINE[0] > 0 And $CMDLINE[1] = "-silent" Then GUISetState(@SW_HIDE, $chinh) Else GUISetState(@SW_SHOW, $chinh) EndIf *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes
LeThanh201 Posted May 29, 2008 Author Posted May 29, 2008 You should call your Script with a Parameter, when it AutoStarts: script.exe -silent In Script: If $CMDLINE[0] > 0 And $CMDLINE[1] = "-silent" Then GUISetState(@SW_HIDE, $chinh) Else GUISetState(@SW_SHOW, $chinh) EndIfThanks for your reply, but I have not understood about $CMDLINE yet, you can guide more , that step by step to create a Parameter and way to use it in my script. Thanks all.
LeThanh201 Posted May 29, 2008 Author Posted May 29, 2008 Em thành công rồi anh ơi, cảm ơn anh nhiều lắm, cảm ơn diễn đàn. Thanks in advance !!!!!!!!!!!!!!!!!!!!1
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