psynegy Posted November 1, 2009 Posted November 1, 2009 Hey, I'm writing a light control app, and I'm trying to work out the best way to run a function, such as a fade, which will happen over a period of time, without affecting the GUI of my application. I suppose (I could be wrong) but I am asking for multi-threading capabilities, or forking or whatever. I'd be interested to know whether it's possible, and if someone could give me an example of executing a function with parameters, which allows the script to continue without waiting for the function to complete it's execution. Hope that's not too jumbled up! Cheers!
Yashied Posted November 1, 2009 Posted November 1, 2009 Only in a separate process. AutoIt does not support multithreading. My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More...
psynegy Posted November 1, 2009 Author Posted November 1, 2009 Interestingly enough, I found what I was looking for. It's not multi-threading as such, but it does exactly what I need it to do. expandcollapse popup#include <GuiConstants.au3> $Gui = GuiCreate("Custom _AdlibEnable Demo", 300, 130) $Left = -200 $Label = GUICtrlCreateLabel("Drag the window, i am just a runing text ;) ", $Left, 100) $RunCheckBox = GUICtrlCreateCheckbox("Run text", 20, 40) GUISetState() While 1 $Msg = GUIGetMsg() Switch $Msg Case -3 _AdlibDisable($Gui) Exit Case $RunCheckBox If GUICtrlRead($RunCheckBox) = 1 Then _AdlibEnable("_TimerFunc", 30, $Gui) Else _AdlibDisable($Gui) EndIf EndSwitch WEnd Func _AdlibEnable($sFunction, $iTime=250, $hWnd=0) Local Const $WM_TIMER = 0x0113 If Not IsHWnd($hWnd) Then $hWnd = GUICreate("hCallBack_AdlibEnable") GUIRegisterMsg($WM_TIMER, $sFunction) Local $aRet = DllCall("User32.dll", "int", "SetTimer", "hwnd", $hWnd, "int", 50, "int", $iTime, "int", 0) Return $hWnd EndFunc Func _AdlibDisable($hWnd=0) Local Const $WM_TIMER = 0x0113 GUIRegisterMsg($WM_TIMER, "") Local $aRet = DllCall("user32.dll", "int", "KillTimer", "hwnd", $hWnd, "int*", 50) Return Number(IsArray($aRet) And $aRet[0]) EndFunc Func _TimerFunc() $Left += 2 If $Left >= 300 Then $Left = -200 ControlMove($Gui, "", $Label, $Left, 100) EndFunc (Example courtesy of MrCreatoR, many thanks!)
monoceres Posted November 1, 2009 Posted November 1, 2009 Multi-threading is hugely overrated. I have almost never used it. Almost any problem can be solved without it. Broken link? PM me and I'll send you the file!
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