Sign in to follow this  
Followers 0
isolation

PostMessage

8 posts in this topic

Hi, I'm trying to add some new threads on a normal autoit executable

I found that the only way to do that is to use guiregistermsg and an internal message code

So I made this piece of script:

#Include <WinAPI.au3>
#include <WindowsConstants.au3>
Global $mymsg=_WinAPI_RegisterWindowMessage("MyNewMsg")
Global $uiui=GUICreate("uuu")
GUIRegisterMsg($mymsg,"lol")
Func lol($a,$b,$c,$d)
    MsgBox(0,$c,$d)
EndFunc
Sleep(1000)
_WinAPI_PostMessage ($uiui,$mymsg,"Hello","uuu")
While 1
    ;.....................................
WEnd

But msgbox displays only 0x000000000000

Share this post


Link to post
Share on other sites



You can't add more threads to AutoIt. a function from GUIRegisterMsg interrupts the whole script until it's finished.


*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

Share this post


Link to post
Share on other sites

Hi, I'm trying to add some new threads on a normal autoit executable

I found that the only way to do that is to use guiregistermsg and an internal message code

So I made this piece of script:

#Include <WinAPI.au3>
#include <WindowsConstants.au3>
Global $mymsg=_WinAPI_RegisterWindowMessage("MyNewMsg")
Global $uiui=GUICreate("uuu")
GUIRegisterMsg($mymsg,"lol")
Func lol($a,$b,$c,$d)
    MsgBox(0,$c,$d)
EndFunc
Sleep(1000)
_WinAPI_PostMessage ($uiui,$mymsg,"Hello","uuu")
While 1
    ;.....................................
WEndoÝ÷ Ø­È£b²ZÊÊ'-1ÓM4ÓM4ÓM4þ«¨µäëÊØb±«­¢+Ø%¹±Õ±Ðí]¥¹A$¹ÔÌÐì(%¹±Õ±Ðí]¥¹½ÝÍ
½¹ÍѹÑ̹ÔÌÐì()±½°ÀÌØíµåµÍõ}]¥¹A%}I¥ÍÑÉ]¥¹½Ý5ÍÍ ÅÕ½Ðí5å9Ý5ÍÅÕ½Ðì¤)±½°ÀÌØíÕ¥Õ¤õU%
ÉÑ ÅÕ½ÐíÕÕÔÅÕ½Ðì¤()U%I¥ÍÑÉ5Í ÀÌØíµåµÍ°ÅÕ½Ðí±½°ÅÕ½Ðì¤()Õ¹±½° ÀÌØí°ÀÌØí°ÀÌØí°ÀÌØí¤($(%±½°ÀÌØíÑMÑÉÕÐô±±MÑÉÕÑ
ÉÑ ÌäíÝ¡ÉlÌäìµÀì9ÕµÈ ÀÌØí¤µÀìÌäítÌäì°ÀÌØí¤($(%5Í  ½à À°ÌäíQÍÐÌäì°±±MÑÉÕÑÑÑ ÀÌØíÑMÑÉÕаĤ¤(¹Õ¹()M±À ÄÀÀÀ¤()±½°ÀÌØíÍAÉ´ôÅÕ½Ðí!±±¼ÅÕ½Ðì)±½°ÀÌØíÑMÑÉÕÐô±±MÑÉÕÑ
ÉÑ ÌäíÝ¡ÉlÌäìµÀìMÑÉ¥¹¡MÑÉ¥¹1¸ ÀÌØíÍAÉ´¤¬Ä¤µÀìÌäítÌäì¤()±±MÑÉÕÑMÑÑ ÀÌØíÑMÑÉÕаİÀÌØíÍAÉ´¤)}]¥¹A%}A½ÍÑ5ÍÍ ÀÌØíÕ¥Õ¤°ÀÌØíµåµÍ°±±MÑÉÕÑÑAÑÈ ÀÌØíÑMÑÉÕФ°±±MÑÉÕÑÑM¥é ÀÌØíÑMÑÉÕФ¼È¤(ÀÌØíÑMÑÉÕÐôÀ()]¡¥±Ä(츸¸¸¸¸¸¸¸¸¸¸¸¸¸¸¸¸¸¸¸¸¸¸¸¸¸¸¸¸¸¸¸¸¸¸¸)]¹

Share this post


Link to post
Share on other sites

Try this.

#Include <WinAPI.au3>
#Include <WindowsConstants.au3>

Global $mymsg=_WinAPI_RegisterWindowMessage("MyNewMsg")
Global $uiui=GUICreate("uuu")

GUIRegisterMsg($mymsg,"lol")

Func lol($a,$b,$c,$d)
    
    local $tStruct = DllStructCreate('wchar[' & Number($d) & ']', $c)
    
    MsgBox(0, 'Test', DllStructGetData($tStruct, 1))
 EndFunc

Sleep(1000)

Global $sParam = "Hello"
Global $tStruct = DllStructCreate('wchar[' & String(StringLen($sParam) + 1) & ']')

DllStructSetData($tStruct, 1, $sParam)
_WinAPI_PostMessage($uiui, $mymsg, DllStructGetPtr($tStruct), DllStructGetSize($tStruct) / 2)
$tStruct = 0

While 1
    ;.....................................
WEnd
It might be worth pointing out that Yashied's example only works because you are reading with the same aplication that sent the message. If you were sending to another preocess then you would need to use the WM_COPYDATA message or use some memory functions.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

tanks, it seems to work

but what ProgAndy wrote is true... :D

I can't have more than a main thread and an adlib

tanks all

Share this post


Link to post
Share on other sites

tanks, it seems to work

but what ProgAndy wrote is true... :o

I can't have more than a main thread and an adlib

tanks all

Of course this will only work within the script. I just corrected the code. If you need to pass a string in another program then see the following.

http://www.autoitscript.com/forum/index.php?showtopic=91346

:D

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Will be developed a version of autoit with threads?

I know that is really difficult to use threads (expecially for base-level developers)

but a special version with threads will help developers a lot!!!!!

Edited by isolation

Share this post


Link to post
Share on other sites

Will be developed a version of autoit with threads?

I know that is really difficult to use threads (expecially for base-level developers)

but a special version with threads will help developers a lot!!!!!

No. The devs have even posted a note that this is one of the features that will not be developed and it should not to be requested.


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0