gahhon Posted December 11, 2018 Posted December 11, 2018 Hi, How can I the trigger the another button functions without waiting the previous function to finish execute? Any advise? I couldn't find any relevant topics via google. Thanks a lot.
moimon Posted December 11, 2018 Posted December 11, 2018 Example code: expandcollapse popup; THư viện không thể thiếu #include <WinAPI.au3> #include <WinAPIShellEx.au3> Global $OldProc ; Đăng kí hàm Callback phụ, với tên hàm là NextProc, các parameter thì để y nguyên hoặc tham khảo trên MSDN nhé Global $hDll = DllCallbackRegister("NextProc", "ptr", "hwnd;uint;long;ptr") ; Get Pointer (C/C++ cân tất =]]) Global $pDll = DllCallbackGetPtr($hDll) ; Tạo một GUI traditional củ chuối... Global $hGUI = GUICreate("Test", 200, 60) ; Tạo 2 button để test để Set và Remove Subclass Global $Btn1 = GUICtrlCreateButton("Subclass", 15, 25, 75, 25) Global $Btn2 = GUICtrlCreateButton("Remove", 110, 25, 75, 25) ; Set Callback phụ $OldProc = _WinAPI_SetWindowLong($hGUI, $GWL_WNDPROC, $pDll) ; Có dòng này để GUI hiện lên chứ, hoặc không cần nếu set $WS_VISIBLE cho style GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case -3 ; Thoát GUIDelete() DllCallbackFree($hDll) Exit Case $Btn1 Case $Btn2 EndSwitch WEnd ;Callback function phụ: NextProc Func NextProc($hWnd, $iMsg, $wParam, $lParam, $iID, $pData) ; Xuất lên Console message của GUI, User khi tương tác với nó, nhớ xem phần console nhé ConsoleWrite(@CRLF & "Msg: " & Hex($iMsg, 4)) If $iMsg = 0x111 Then ;$WM_Command Switch $lParam ; $lParam trả về handle của control vừa tương tác Case GUICtrlGetHandle($Btn1) MsgBox(0, "", "Button 1 Clicked") Case GUICtrlGetHandle($Btn2) MsgBox(0, "", "Button 2 Clicked") ; Vô tư click... EndSwitch EndIf ; Luôn có dòng này đề tránh lỗi Return _WinAPI_CallWindowProc($OldProc, $hWnd, $iMsg, $wParam, $lParam) ;Dùng hàm dưới để Define (Unicode) thay cho hàm trên (ANSI), nhớ thêm #include <WinAPISys.au3> ;Return _WinAPI_CallWindowProcW($hWnd, $iMsg, $wParam, $lParam) EndFunc Source: https://translate.google.com.vn/translate?hl=en&tab=wT&sl=auto&tl=en&u=http%3A%2F%2Fautoitvn.com%2Fthreads%2Fadvanced-callback-phuong-phap-da-luong-trong-autoit.1254%2F
gahhon Posted December 11, 2018 Author Posted December 11, 2018 I don't understand the code you shared. Could you please explain about the flow to me? @@
Developers Jos Posted December 11, 2018 Developers Posted December 11, 2018 @gahhon, I find it remarkable that somebody was able to answer your post at all as it is pretty vague. What about you show us some sort of scriptlet that shows what you want but isn't working yet? Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
Moderators Melba23 Posted December 11, 2018 Moderators Posted December 11, 2018 gahhon, The Interrupting a running function tutorial in the Wiki will explain how to do what you want. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
gahhon Posted December 11, 2018 Author Posted December 11, 2018 I haven't try any code yet because I couldn't find any relevant topic from Google. My design of the GUI is several buttons, then control them by using Switch-Statement as usual. While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $btnJack Jack() Case $btnVongola Vongola() EndSwitch WEnd
Developers Jos Posted December 11, 2018 Developers Posted December 11, 2018 That piece of code doesn't show any issue nor can it be ran to demonstrate it. Please post something which is clear and understandable. Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
gahhon Posted December 12, 2018 Author Posted December 12, 2018 expandcollapse popup#include <IE.au3> #include <excel.au3> #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $FormGUI1 = GUICreate("GUI1", 485, 344, -1, -1, BitOR($GUI_SS_DEFAULT_GUI,$WS_MAXIMIZEBOX,$WS_SIZEBOX,$WS_THICKFRAME,$WS_TABSTOP)) GUISetCursor (2) GUISetBkColor(0x0450CC) Global $btnJack = GUICtrlCreateButton("Jack", 34, 36, 136, 38) GUICtrlSetFont(-1, 10, 400, 0, "Imprint MT Shadow") Global $btnVongola = GUICtrlCreateButton("Vongola", 212, 36, 136, 38) GUICtrlSetFont(-1, 10, 400, 0, "Imprint MT Shadow") GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $btnJack Jack() Case $btnVongola Vongola() EndSwitch WEnd Func Jack() <function code> EndFunc Func Vongola() <function code> EndFunc
Moderators Melba23 Posted December 12, 2018 Moderators Posted December 12, 2018 gahhon, Did you bother to read the tutorial to which I linked you in this earlier post of mine? It explains, as its title suggest, exactly how to interrupt a running function in AutoIt - which is the very same question you have asked. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
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