Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > AutoIt
You last visited: Today at 04:14

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



[AUTOIT] Change Pic control image of external Autoit-GUI

Discussion on [AUTOIT] Change Pic control image of external Autoit-GUI within the AutoIt forum part of the Coders Den category.

Reply
 
Old   #1
 
fuso98's Avatar
 
elite*gold: 428
Join Date: Dec 2011
Posts: 2,722
Received Thanks: 2,035
[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

Thanks in advance
fuso98 is offline  
Old 01/25/2016, 18:12   #2
 
alpines's Avatar
 
elite*gold: 60
Join Date: Aug 2009
Posts: 2,256
Received Thanks: 815
Maybe _ImageLoadFromFile doesn't load the picture properly as a bitmap. Try using _GDIPlus_BitmapCreateFromFile instead.
alpines is offline  
Old 01/25/2016, 18:43   #3
 
fuso98's Avatar
 
elite*gold: 428
Join Date: Dec 2011
Posts: 2,722
Received Thanks: 2,035
I've used it too but it don't work
fuso98 is offline  
Old 01/25/2016, 22:44   #4
 
Shadow992's Avatar
 
elite*gold: 77
Join Date: May 2008
Posts: 5,430
Received Thanks: 5,878
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.
Shadow992 is offline  
Old 01/25/2016, 23:04   #5
 
fuso98's Avatar
 
elite*gold: 428
Join Date: Dec 2011
Posts: 2,722
Received Thanks: 2,035
I tried with GDI+ but obviusly I can use every working method. Do you have other suggestions?
fuso98 is offline  
Old 01/26/2016, 07:29   #6

 
Moneypulation's Avatar
 
elite*gold: 138
Join Date: Apr 2012
Posts: 3,494
Received Thanks: 1,769
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
Moneypulation is offline  
Old 01/26/2016, 14:39   #7
 
fuso98's Avatar
 
elite*gold: 428
Join Date: Dec 2011
Posts: 2,722
Received Thanks: 2,035
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.
fuso98 is offline  
Old 01/26/2016, 19:47   #8
 
YatoDev's Avatar
 
elite*gold: 50
Join Date: Sep 2012
Posts: 3,841
Received Thanks: 1,462
Quote:
Originally Posted by fuso98 View Post
much time as it's needed to update the preview.
you do not have 10ms?
YatoDev is offline  
Old 01/27/2016, 22:02   #9
 
fuso98's Avatar
 
elite*gold: 428
Join Date: Dec 2011
Posts: 2,722
Received Thanks: 2,035
Taking a screenshot don't take me 10ms.
fuso98 is offline  
Old 01/28/2016, 03:13   #10
 
YatoDev's Avatar
 
elite*gold: 50
Join Date: Sep 2012
Posts: 3,841
Received Thanks: 1,462
why not simply draw it from another process onto your window?
YatoDev is offline  
Old 01/28/2016, 07:27   #11
 
FacePalmMan's Avatar
 
elite*gold: 0
Join Date: Jan 2013
Posts: 426
Received Thanks: 129
What about running your second script as a child process? Works for sharing TCP Handles (example: My powerful webserver).
FacePalmMan is offline  
Old 01/28/2016, 20:13   #12
 
fuso98's Avatar
 
elite*gold: 428
Join Date: Dec 2011
Posts: 2,722
Received Thanks: 2,035
Quote:
Originally Posted by »FlutterShy™ View Post
why not simply draw it from another process onto your window?
I'm trying to do this. I want to do this, but the code that I posted in the first post don't work

Quote:
Originally Posted by FacePalmMan View Post
What about running your second script as a child process? Works for sharing TCP Handles (example: My powerful webserver).
How to create a child process?
fuso98 is offline  
Old 01/31/2016, 12:46   #13
 
FacePalmMan's Avatar
 
elite*gold: 0
Join Date: Jan 2013
Posts: 426
Received Thanks: 129
Code:
$PID = Run("Childprogram " & $TheHandleToTheGraphics, "", Default, 3)
(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
FacePalmMan is offline  
Old 01/31/2016, 12:59   #14
 
YatoDev's Avatar
 
elite*gold: 50
Join Date: Sep 2012
Posts: 3,841
Received Thanks: 1,462
Just draw the pic onto the gui with gdi plus
YatoDev is offline  
Thanks
2 Users
Old 01/31/2016, 13:08   #15
 
FacePalmMan's Avatar
 
elite*gold: 0
Join Date: Jan 2013
Posts: 426
Received Thanks: 129
_GDIPlus_GraphicsCreateFromHWND()
_GDIPlus_ImageLoadFromFile()
_GDIPlus_GraphicsDrawImage()
^ there you have it.
FacePalmMan is offline  
Thanks
1 User
Reply


Similar Threads Similar Threads
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:



All times are GMT +1. The time now is 04:15.


Powered by vBulletin®
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2025 elitepvpers All Rights Reserved.