StMaSi Posted Monday at 07:23 PM Posted Monday at 07:23 PM When AU3 script is run from right-click > run script, the background images, on the forms, are displayed correctly. However, when the compiled EXE is run, the background images are missing. Advice? Suggestions? Thanks in advance. expandcollapse popup#include <AutoItConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Global $Form_Intro = GUICreate("Intro form", 463, 266, -1, -1, $WS_POPUP & BITOR($WS_EX_LAYERED, $WS_EX_TOOLWINDOW)) Global $Pic_Intro = GUICtrlCreatePic(@ScriptDir & "\intro.jpg", 0, 0, 463, 266, $GUI_DISABLE) Global $Button1_Intro = GUICtrlCreateButton("One", 175, 234, 49, 25) Global $Button2_Intro = GUICtrlCreateButton("Two", 229, 234, 49, 25) Global $Button3_Intro = GUICtrlCreateButton("Three", 283, 234, 49, 25) Global $Button4_Intro = GUICtrlCreateButton("Cancel", 358, 234, 97, 25) _Intro() Func _Intro() WinSetOnTop($Form_Intro, "", $WINDOWS_ONTOP) GUISetState(@SW_SHOW, $Form_Intro) While 1 $Msg_Welcome = GUIGetMsg() Switch $Msg_Welcome Case $Button1_Intro GUISetState(@SW_HIDE, $Form_Intro) _One_Ask() Exit Case $Button2_Intro GUISetState(@SW_HIDE, $Form_Intro) _Two_Ask() Exit Case $Button3_Intro GUISetState(@SW_HIDE, $Form_Intro) _Three_Ask() Exit Case $Button4_Intro GUISetState(@SW_HIDE, $Form_Intro) _Cancel_Ask() EndSwitch WEnd EndFunc
SOLVE-SMART Posted Monday at 07:34 PM Posted Monday at 07:34 PM Hi @StMaSi 👋 , this is not reproducable on my side. The intro.jpg is displayed as running script and also as running *.exe. Are you sure your intro.jpg is a JPG/JPEG? Because PNG is not visible out of the box in your shown way. Please try with an other JPG image. Best regards Sven Stay innovative! Spoiler 🌍 Au3Forums 🎲 AutoIt (en) Cheat Sheet 📊 AutoIt limits/defaults 💎 Code Katas: [...] (comming soon) 🎭 Collection of GitHub users with AutoIt projects 🐞 False-Positives 🔮 Me on GitHub 💬 Opinion about new forum sub category 📑 UDF wiki list ✂ VSCode-AutoItSnippets 📑 WebDriver FAQs 👨🏫 WebDriver Tutorial (coming soon)
Nine Posted Monday at 07:34 PM Posted Monday at 07:34 PM Your GUI create is wrong. Try this : Global $Form_Intro = GUICreate("Intro form", 463, 266, -1, -1, $WS_POPUP, $WS_EX_TOOLWINDOW) SOLVE-SMART 1 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy
SOLVE-SMART Posted Monday at 07:39 PM Posted Monday at 07:39 PM Yes @Nine, that's come on top of it. But the wrong style will be ignored and the image is shown (at least with my "intro.jpg"). Stay innovative! Spoiler 🌍 Au3Forums 🎲 AutoIt (en) Cheat Sheet 📊 AutoIt limits/defaults 💎 Code Katas: [...] (comming soon) 🎭 Collection of GitHub users with AutoIt projects 🐞 False-Positives 🔮 Me on GitHub 💬 Opinion about new forum sub category 📑 UDF wiki list ✂ VSCode-AutoItSnippets 📑 WebDriver FAQs 👨🏫 WebDriver Tutorial (coming soon)
StMaSi Posted Monday at 07:41 PM Author Posted Monday at 07:41 PM SOLVE-SMART, yes, the images are JPG files as I created them myself in GIMP and exported as JPG. I have tried with many JPGs, even generic ones downloaded from the net. Unfortunately, after further testing, the EXE is functioning properly on other computers, so it may be just this one computer having some unknown issue. Nine, unfortunately, the change in the GUI create didn't make a difference.
Developers Jos Posted Monday at 07:46 PM Developers Posted Monday at 07:46 PM (edited) Is the exe in another directory when it is failing to display the jpg as it isn't included in the exe? Edited Monday at 08:08 PM by Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
StMaSi Posted Monday at 08:03 PM Author Posted Monday at 08:03 PM The scriptdir contains the au3 file and all jpg files. From within SciTE, I compile (Tools > Compile) the au3 from that folder. No errors or issues during compilation. After that, I transfer only the compiled EXE to computers. So, far, it is just this single computer that isn't showing the background images. Just can't wrap my head around it. No errors in the Windows event viewer and nothing out of the ordinary showing up in ProcMon, so I'm at a loss.
Nine Posted Monday at 08:06 PM Posted Monday at 08:06 PM 3 minutes ago, StMaSi said: I transfer only the compiled EXE to computers You need to transfer the JPG files used by the EXE as well. “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy
Developers Jos Posted Monday at 08:07 PM Developers Posted Monday at 08:07 PM (edited) Long story for a simple question Yes/No! The reason it won't show is that you load the image with this statement.. right?: Global $Pic_Intro = GUICtrlCreatePic(@ScriptDir & "\intro.jpg", 0, 0, 463, 266, $GUI_DISABLE) So when you compile the script into an exe, the @scripdir macro variable will contain the subdirectory the exe is moved to, which doesn't contain the jpg...right? Edited Monday at 08:09 PM by Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
StMaSi Posted Monday at 08:12 PM Author Posted Monday at 08:12 PM So, there's no way to "include" the jpg files into the EXE?
Developers Jos Posted Monday at 08:14 PM Developers Posted Monday at 08:14 PM Just now, StMaSi said: So, there's no way to "include" the jpg files into the EXE? This is not what I said, merely explained why it isn't working. Yes there are several options to include the jpg file. Have you tried searching for this, as this is asked before? SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
StMaSi Posted Monday at 08:18 PM Author Posted Monday at 08:18 PM I did not. I will search now. Thanx.
Nine Posted Monday at 11:21 PM Posted Monday at 11:21 PM (edited) @StMaSi Well, I wanted to have simple clean script to show any JPG directly included inside the EXE. So this is what end up with : expandcollapse popup#AutoIt3Wrapper_Res_File_Add=Intro.jpg, rt_rcdata, ResFile #include <GUIConstants.au3> #include <WinAPISys.au3> #include <WinAPIRes.au3> #include <Memory.au3> #include <GDIPlus.au3> #include <WinAPICom.au3> #include <StaticConstants.au3> Opt("MustDeclareVars", True) If Not @Compiled Then Exit MsgBox($MB_OK, "Error", "This script needs to be compiled") Example() Func Example() Local $hGUI = GUICreate("Example", 500, 400, -1, -1, $WS_POPUP, BitOR($WS_EX_TOOLWINDOW, $WS_EX_TOPMOST, $WS_EX_CONTROLPARENT)) Local $idBackGround = GUICtrlCreatePic("", 0, 0, 500, 400, $GUI_DISABLE) Local $idCancel = GUICtrlCreateButton("Cancel", 400, 370, 90, 25) Local $hBitmap = GetResImage("ResFile", 500, 400) GUICtrlSendMsg($idBackGround, $STM_SETIMAGE, $IMAGE_BITMAP, $hBitmap) _WinAPI_DeleteObject($hBitmap) GUISetState() While True Switch GUIGetMsg() Case $idCancel ExitLoop EndSwitch WEnd EndFunc ;==>Example Func GetResImage($sName, $iWidth = Default, $iHeight = Default) _GDIPlus_Startup() Local $hInstance = _WinAPI_GetModuleHandle(0) Local $hResource = _WinAPI_FindResource($hInstance, $RT_RCDATA, $sName) Local $nSize = _WinAPI_SizeOfResource($hInstance, $hResource) Local $hData = _WinAPI_LoadResource($hInstance, $hResource) Local $pResData = _WinAPI_LockResource($hData) $hData = _MemGlobalAlloc($nSize, $GMEM_MOVEABLE) Local $pData = _MemGlobalLock($hData) _MemMoveMemory($pResData, $pData, $nSize) _MemGlobalUnlock($hData) Local $pStream = _WinAPI_CreateStreamOnHGlobal($hData, True) Local $hImage = _GDIPlus_BitmapCreateFromStream($pStream) _WinAPI_ReleaseStream($pStream) Local $hResize, $hBitmap If $iWidth <> Default Or $iHeight <> Default Then If $iWidth = Default Then $iWidth = _GDIPlus_ImageGetWidth($hImage) If $iHeight = Default Then $iHeight = _GDIPlus_ImageGetHeight($hImage) $hResize = _GDIPlus_ImageResize($hImage, $iWidth, $iHeight) $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hResize) _GDIPlus_ImageDispose($hResize) Else $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage) EndIf _GDIPlus_ImageDispose($hImage) _GDIPlus_Shutdown() Return $hBitmap EndFunc ;==>GetResImage Edited Tuesday at 01:37 PM by Nine Revised code “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy
Developers Jos Posted Tuesday at 08:18 AM Developers Posted Tuesday at 08:18 AM 8 hours ago, Nine said: Well, I wanted to have simple clean script to show any JPG directly included inside the EXE. @StMaSi, this example requires the Separate SciTE4AutoIt3 installer which includes AutoIt3Wrapper required for the first line directive. SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
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