ThanhDuy Posted October 9, 2009 Share Posted October 9, 2009 This is my code. I just know a litle about createthread. Some problem with my code, i can't fix. Please help me expandcollapse popup#include <ButtonConstants.au3> #include <ComboConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <GUIListBox.au3> #include <GuiStatusBar.au3> #include <SliderConstants.au3> #include <StaticConstants.au3> #include <TabConstants.au3> #include <WindowsConstants.au3> Dim $AvatarPic Dim $button Dim $thread = False Dim $loaded = False Func FunctionThread() ;$nick = "thanhduyphp" InetGet("http://img.msg.yahoo.com/avatar.php?yids=thanhduyphp&format=gif","#.gif") $loaded = True $thread = False ;ConsoleWrite("~~~~~~~~~End thread" & @CRLF) ;$b = TimerInit() ;While TimerDiff($b) < 10000 ;WEnd ;ConsoleWrite("############End thread" & @CRLF) EndFunc Func Handle() If FileExists("#.gif") Then FileDelete("#.gif") Local $handle = DllCallbackRegister("FunctionThread","int","") DllCall("kernel32.dll","hwnd","CreateThread","ptr",0,"int",0,"ptr",DllCallbackGetPtr($handle),"ptr",0,"dword",0,"ptr",0) ConsoleWrite("----------> Start thread" & @CRLF) EndFunc GUICreate("Gui Test",200,300) $button = GUICtrlCreateButton("Get Avarta",15,15) $AvatarPic = GUICtrlCreatePic("", 16, 88, 96, 96, BitOR($SS_NOPREFIX,$SS_NOTIFY,$SS_RIGHTJUST,$WS_GROUP,$WS_TABSTOP,$WS_BORDER)) GUISetState() While 1 Local $msg = GUIGetMsg() IF $msg == $button and Not $thread Then $thread = True Handle() EndIf If $msg == $GUI_EVENT_CLOSE Then Exit If $loaded Then $loaded = False GUICtrlSetImage( $AvatarPic , "#.gif") ;FileDelete("#.gif") EndIf WEnd Link to comment Share on other sites More sharing options...
Andreik Posted October 9, 2009 Share Posted October 9, 2009 What exactly you want to do? When the words fail... music speaks. Link to comment Share on other sites More sharing options...
ThanhDuy Posted October 9, 2009 Author Share Posted October 9, 2009 What exactly you want to do? It still have a big error. Can you fix it for me. >"C:\Program Files\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /run /prod /ErrorStdOut /in "C:\Users\SONY VAIO\Documents\AutoIt\Test2.au3" /autoit3dir "C:\Program Files\AutoIt3" /UserParams +>16:42:28 Starting AutoIt3Wrapper v.2.0.0.1 Environment(Language:0409 Keyboard:00000409 OS:WIN_VISTA/ CPU:X64 OS:X86) >Running AU3Check (1.54.14.0) from:C:\Program Files\AutoIt3 +>16:42:29 AU3Check ended.rc:0 >Running:(3.3.0.0):C:\Program Files\AutoIt3\autoit3.exe "C:\Users\SONY VAIO\Documents\AutoIt\Test2.au3" ----------> Start thread !>16:42:39 AutoIT3.exe ended.rc:-1073741819 +>16:42:40 AutoIt3Wrapper Finished >Exit code: -1073741819 Time: 11.501 Link to comment Share on other sites More sharing options...
Andreik Posted October 9, 2009 Share Posted October 9, 2009 For me work fine on WinXP Professional SP3. I saw that you use Win Vista, maybe this is the problem. Please tell me what you what to do and maybe I can help you? You want just to get the yahoo avatar and put in your GUI? When the words fail... music speaks. Link to comment Share on other sites More sharing options...
jvanegmond Posted October 9, 2009 Share Posted October 9, 2009 If you're trying multi-threading then you can forget it. github.com/jvanegmond Link to comment Share on other sites More sharing options...
monoceres Posted October 9, 2009 Share Posted October 9, 2009 AutoIt is not thread-safe so pointing new threads to autoit callbacks will sooner or later make code collide and crash pretty hard. You'll have to rethink your logic or implement the thread in a different language. Broken link? PM me and I'll send you the file! Link to comment Share on other sites More sharing options...
Yashied Posted October 9, 2009 Share Posted October 9, 2009 Alternatively, you can use multiple processes. Personally, I am doing just that. 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... Link to comment Share on other sites More sharing options...
jvanegmond Posted October 9, 2009 Share Posted October 9, 2009 Actually, all you're doing is making an InetGet call which can be done async. Just look at the helpfile for InetGet. github.com/jvanegmond Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted October 9, 2009 Share Posted October 9, 2009 Actually, all you're doing is making an InetGet call which can be done async. Just look at the helpfile for InetGet.And if you install the Beta (>= 3.3.1.0), you can have multiple downloads with the "background" parameter .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
ThanhDuy Posted October 9, 2009 Author Share Posted October 9, 2009 My progam is get avatar and check that yahoo's invisible or offline. But it still take the long time have a response from sever. Thus, i want to create thread to do that thing. The program don't need to wait response from server. it can do some thing else. This is my soft. http://www.mediafire.com/?eicyomzjmtm Link to comment Share on other sites More sharing options...
Yashied Posted October 9, 2009 Share Posted October 9, 2009 (edited) My progam is get avatar and check that yahoo's invisible or offline. But it still take the long time have a response from sever. Thus, i want to create thread to do that thing. The program don't need to wait response from server. it can do some thing else.This is my soft.http://www.mediafire.com/?eicyomzjmtmI repeat, you can create a separate process for this and use WM_COPYDATA for communicate between processes. Multithreading will not work in AutoIt. He does not designed for this. Edited October 9, 2009 by Yashied 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... Link to comment Share on other sites More sharing options...
wolf9228 Posted October 9, 2009 Share Posted October 9, 2009 I repeat, you can create a separate process for this and use WM_COPYDATA for communicate between processes. Multithreading will not work in AutoIt. He does not designed for this. http://msdn.microsoft.com/en-us/library/ms682453(VS.85).aspx CreateThread Function Creates a thread to execute within the virtual address space of the calling process. To create a thread that runs in the virtual address space of another process, use the CreateRemoteThread function. But in Autoit that is not possible except by using Assembly language Through the Autoit language Such an example in this topic Execute in a different thread http://www.autoitscript.com/forum/index....&st=0&p=686626&fromsearch=1&#entry686626 in Autoit Function does not work properly as this example #include <GUIConstantsEx.au3> GUICreate("CreateThread") $Button = GUICtrlCreateButton("CreateThread", 10, 30, 150) GUISetState() $i1 = 0 While 1 $i1 += 1 ToolTip("LOOP1 = " & $i1,200, 100) $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $Button $handle = DLLCallbackRegister ("ThreadProc", "int", "ptr") $Return = DllCall("Kernel32.dll","hwnd","CreateThread","ptr",0,"int",0,"ptr",DllCallbackGetPtr($handle),"ptr",0,"int",0,"ptr*",0) $handle = $Return[0] $lpThreadId = $Return[6] EndSelect WEnd Func ThreadProc($lpParameter) $i2 = 0 While 1 if GUIGetMsg() = $GUI_EVENT_CLOSE Then Exit $i2 += 1 ToolTip("LOOP2 = " & $i2,300, 100) WEnd EndFunc صرح السماء كان هنا 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