NassauSky Posted January 29, 2015 Share Posted January 29, 2015 I have found a few old scripts with ideas on how to use graphics from the web. Everything I have tried has come up with errors. A few examples use the variable $ghGDIPDLL and this looks like it is because Autoit code has changed over time. I added Global $ghGDIPDLL = $__g_hGDIPDll to the beginning of the samples of code but then there were other errors like $hBitmap = $hBitmap[2] Error:Subscript used on non-accessible variable. Does anyone have complete recent code that works in the latest Autoit that can start a basic gui with a single button on it of any graphic from the web. From that I can probably figure out how to add it to my app. Thanks for all help. Link to comment Share on other sites More sharing options...
SadBunny Posted January 29, 2015 Share Posted January 29, 2015 No need to work with WMI or dll's or whatnot... Here's what I would do. Save the downloaded file, then use it in the GUICtrlSetImage. Hopefully this is what you're looking for. #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> Example() Func Example() GUICreate("My GUI") ; will create a dialog box that when displayed is centered GUICtrlCreateButton("my picture button", 10, 20, 60, 60, $BS_BITMAP) GUICtrlSetImage(-1, "c:\Temp\something.bmp") GUISetState(@SW_SHOW) ; Loop until the user exits. While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd EndFunc ;==>Example Roses are FF0000, violets are 0000FF... All my base are belong to you. Link to comment Share on other sites More sharing options...
NassauSky Posted January 29, 2015 Author Share Posted January 29, 2015 (edited) No need to work with WMI or dll's or whatnot... Here's what I would do. Save the downloaded file, then use it in the GUICtrlSetImage. Hopefully this is what you're looking for. #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> Example() Func Example() GUICreate("My GUI") ; will create a dialog box that when displayed is centered GUICtrlCreateButton("my picture button", 10, 20, 60, 60, $BS_BITMAP) GUICtrlSetImage(-1, "c:\Temp\something.bmp") GUISetState(@SW_SHOW) ; Loop until the user exits. While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd EndFunc ;==>Example Thanks the website images change frequently. Either I will need to find code to have autoit download these to a local file dynamically or I might still need code to display the image directly from the website on the buttons. I will think about this. If anyone else has other ideas it would be great too. Thanks @sadbunny I will see about maybe using inetget together with your code. Edited January 29, 2015 by nassausky Link to comment Share on other sites More sharing options...
Solution UEZ Posted January 29, 2015 Solution Share Posted January 29, 2015 Try this: #include <GDIplus.au3> #include <GUIConstantsEx.au3> #include <ButtonConstants.au3> _GDIPlus_Startup() Global $hHBitmap = _GDIPlus_BitmapCreateFromMemory(InetRead("http://icons.iconarchive.com/icons/hopstarter/soft-scraps/64/User-Administrator-Blue-icon.png"), 1) Global $hGUI = GUICreate("Bitmap from inet", 300, 200) GUISetBkColor(0xFFFFFF) Global $iBtn = GUICtrlCreateButton("", (300 - 72) / 2, (200 - 72) / 2, 72, 72, $BS_BITMAP), $hBtn = GUICtrlGetHandle($iBtn) _WinAPI_DeleteObject(_SendMessage($hBtn, $BM_SETIMAGE, $IMAGE_BITMAP, $hHBitmap)) GUISetState() Do Switch GUIGetMsg() Case $GUI_EVENT_CLOSE _WinAPI_DeleteObject($hHBitmap) _GDIPlus_Shutdown() GUIDelete() Exit Case $iBtn MsgBox(0, "Info", "Image in button was downloaded from web and used directly without saving to disk first!") EndSwitch Until False Br, UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
NassauSky Posted January 29, 2015 Author Share Posted January 29, 2015 Excellent @UEZ just what I was looking for. I'm going to play with that a bit and thanks again @SadBunny for the option. Link to comment Share on other sites More sharing options...
dynamitemedia Posted January 13, 2016 Share Posted January 13, 2016 this is awesome but i have a question how can we get the original image say its 480 x 560 but we want to fit into a button that 240 x 280 just for an example Link to comment Share on other sites More sharing options...
dynamitemedia Posted January 13, 2016 Share Posted January 13, 2016 No need to work with WMI or dll's or whatnot... Here's what I would do. Save the downloaded file, then use it in the GUICtrlSetImage. Hopefully this is what you're looking for.#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> Example() Func Example() GUICreate("My GUI") ; will create a dialog box that when displayed is centered GUICtrlCreateButton("my picture button", 10, 20, 60, 60, $BS_BITMAP) GUICtrlSetImage(-1, "c:\Temp\something.bmp") GUISetState(@SW_SHOW) ; Loop until the user exits. While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd EndFunc ;==>Examplei cant get this to work at all...i was thinking it was because of spaces in the folder files as such: "C:\Documents and Settings\settop\Desktop\Imgs/ArIII.bmpso i changed the code to this:Func Example() GUICreate("My GUI") ; will create a dialog box that when displayed is centered $img = "/Imgs/ArIII.bmp" $load = '"' & @ScriptDir & $img & '"' ConsoleWrite( "Image Used: " & $load & @CRLF ) ; If you're in SciTE $Btn = GUICtrlCreateButton("my picture button", 10, 10, 260, 260, $BS_BITMAP) ;_GUICtrlButton_SetImage($Btn, $load) GUICtrlSetImage(-1, $load) GUISetState(@SW_SHOW) ; Loop until the user exits. While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd EndFunc ;==>Exampleany idea why it is not showing the image at all? Link to comment Share on other sites More sharing options...
UEZ Posted January 13, 2016 Share Posted January 13, 2016 Try$load = @ScriptDir & $imginstead and be sure that the file is in script dir. Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
dynamitemedia Posted January 13, 2016 Share Posted January 13, 2016 Try$load = @ScriptDir & $imginstead and be sure that the file is in script dir.same thing nothing showing up as far as pic goes... the console is writing out the location so i know it is correct location Link to comment Share on other sites More sharing options...
UEZ Posted January 13, 2016 Share Posted January 13, 2016 This works for me:Func Example() GUICreate("My GUI") ; will create a dialog box that when displayed is centered $img = "\Imgs\ArIII.bmp" $load = @ScriptDir & $img ConsoleWrite( "Image Used: " & $load & @CRLF ) ; If you're in SciTE $Btn = GUICtrlCreateButton("my picture button", 10, 10, 260, 260, $BS_BITMAP) ;_GUICtrlButton_SetImage($Btn, $load) GUICtrlSetImage(-1, $load) GUISetState(@SW_SHOW) ; Loop until the user exits. While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd EndFunc ;==>Example Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
dynamitemedia Posted January 13, 2016 Share Posted January 13, 2016 strange still nothing... you think i am missing a au3 file? Link to comment Share on other sites More sharing options...
BrewManNH Posted January 14, 2016 Share Posted January 14, 2016 A wise man on here once said, if you want help with code post the code, if you want help with a picture post a picture of your code. No one is going to type in your code from a picture of it.(yes, I know it's posted in UEZ's post, just a friendly reminder) If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
dynamitemedia Posted January 14, 2016 Share Posted January 14, 2016 i know, i wanted to show that the code is NOT showing the image Link to comment Share on other sites More sharing options...
BrewManNH Posted January 14, 2016 Share Posted January 14, 2016 Do you have a link to the image file you're using so we can test it with the same image? If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
dynamitemedia Posted January 14, 2016 Share Posted January 14, 2016 its any image not just this one. but i added it ArIII.bmp Link to comment Share on other sites More sharing options...
UEZ Posted January 14, 2016 Share Posted January 14, 2016 The image is not in bmp format - it is a jpg. Just convert it to bmp format and it should work. Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
dynamitemedia Posted January 15, 2016 Share Posted January 15, 2016 but it say .bmp and i even tried using some of your code to get it to work in case it is not a bmp and still not working #include <GDIplus.au3> #include <GUIConstantsEx.au3> #include <ButtonConstants.au3> _GDIPlus_Startup() Local Const $iWidth = 300, $iHeight = 300, $iBgColor = 0xFFE8FF ;$iBgColor format RRGGBB Global $img = "\Imgs\ArIII.bmp" Global $load = @ScriptDir & $img Global $hGUI = GUICreate("Bitmap from inet", 800, 600) GUISetBkColor(0xFFFFFF) ;Global $hHBitmap = _GDIPlus_BitmapCreateFromMemory(InetRead("http://icons.iconarchive.com/icons/hopstarter/soft-scraps/64/User-Administrator-Blue-icon.png"), 1) Global $hHBitmap = _GDIPlus_BitmapCreateFromMemory($load, 1) Global $iBtn = GUICtrlCreateButton("", (300 - 72) / 2, (200 - 72) / 2, 272, 272, $BS_BITMAP), $hBtn = GUICtrlGetHandle($iBtn) _WinAPI_DeleteObject(_SendMessage($hBtn, $BM_SETIMAGE, $IMAGE_BITMAP, $hHBitmap)) GUISetState() Do Switch GUIGetMsg() Case $GUI_EVENT_CLOSE _WinAPI_DeleteObject($hHBitmap) _GDIPlus_Shutdown() GUIDelete() Exit Case $iBtn MsgBox(0, "Info", "Image in button was downloaded from web and used directly without saving to disk first!") EndSwitch Until False Link to comment Share on other sites More sharing options...
BrewManNH Posted January 15, 2016 Share Posted January 15, 2016 The file is a jpg with a bmp extension. If you open it in paint and just "Save As" a bmp them rerun your script you will see the image on the button. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
dynamitemedia Posted January 15, 2016 Share Posted January 15, 2016 i understand that i wont be able to always control that so i want to do it via the code Link to comment Share on other sites More sharing options...
dynamitemedia Posted January 15, 2016 Share Posted January 15, 2016 i understand that i wont be able to always control that so i want to do it via the code That did work, but again if i am just grabbing .png or a jpg from a api or xml file i need to do a different method i am going to try that with the code presented above and come back 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