[AUTOIT] Change Pic control image of external Autoit-GUI
Hi guys, I've a problem and maybe some one that know more than me can help me to solve it.
I've 1 gui made in autoit, It simply act in background in a game window. Cause it is fully in background I want to add preview of the window where I do actions. So I decided to make 2 autoit scripts.
The script A perform actions in the game.
The script B should get the preview of the game and edit the Pic control image (GuiCtrlCreatePic) in the script A GUI.
In the script B i've this code:
Code:
Local $hWnd = ControlGetHandle("Script A GUI","","[CLASS:Static; INSTANCE:10]")
_GDIPlus_Startup()
$himage = _GDIPlus_ImageLoadFromFile("test.bmp")
$HBITMAP = _GDIPlus_BitmapCreateHBITMAPFromBitmap($himage)
_SendMessage($hWnd,$STM_SETIMAGE,$IMAGE_BITMAP,$HBITMAP)
Exit
But it simply don't work. At the start the pic control has a black image. After the execution of script B the control Pic seems to be empty, so I'm sure that something happened but I can't figure out to make it working
I guess the problem is the memory you use.
I do not know anything exact about how to set an image but as I guess the process A cannot acces the memory allocated by process B. This may be because of the fact that SendMessage just does not support this, it could also be something AutoIt specific or just a natural thing.
I am also not sure if AutoIt handles these "bitmap-handles" correctly. As I guess (because my language follows an similar approach), whenever you pass a variable to an AutoIt-Function it only passes an object which may be called "AutoItVariable" to the function.
This "AutoItVariable" may have an attribute called "value" where the real pointer to the bitmap lies.
So theoretically it may be possible that AutoIt not copies the pointer of the bitmap but the pointer of the variableand sends this pointer of variable to the other process.
As stated earlier, these are just a few theories you could examine. I did not test it nor did I ever try something similar. So my theories may be completely wrong, just test them one by one.
If you haven't got any other options, you can do both actions in one script. Eventhough you can't use multithreading in AutoIt, there is a way to do both, botting and updating the preview "simultaneously". I figured when my bot was still written in AutoIt that you can replace the Sleep() function, which you probably use often, with an adapted version of it where you update the preview in a loop until the time you set through the parameter runs off. Of course this isn't the best way to fix your problem but it worked for me
Yeah but in this way, It will not update during the search loop just because there aren't sleeps in it, or at least there aren't sleep with much time as it's needed to update the preview.
(if graphics handle is created later, then you can do StdInWrite($PID, $TheHandleToTheGraphics))
Then you only need to copy the handle using some commands.
I am not sure what commands are needed, but it should be something like _GDIPlus_DuplicateHandle
Autoit image search inside another image 12/30/2015 - AutoIt - 2 Replies Hi guys. I saw others asking this question: how to search an image inside another one, but no one got a nice answer. So here I am, asking this again, maybe with some luck this time. :pimp:
Ok, so let me ask with a little more details. I know I have to create a memory bitmap and search it inside another bitmap. I tried some UDFs but none of them works :confused: I hope i will get some help from you :handsdown: