VJA Posted May 14, 2021 Share Posted May 14, 2021 Hi there, I'm trying to figure out where I went wrong with my script, surely I'm missing something simple, thought I better ask the geniuses. I have a gui box the same size as the jpg, but it keeps putting the jpg very tiny in the top left corner. I've tried changing -1,-1,0,0, to all sorts of numbers without success. Would anyone be so kind to provide any guidance? FileInstall('Auto-It\screenpop\Workday\workday1.JPG', @ScriptDir & "\test.jpg",1);Prompt Graphic If WinExists("Notification") Then Exit EndIf #Region ### START GUI section and File Install### $gui = GUICreate("Notification", 556, 625, Default, Default, BitOr($WS_CAPTION, $WS_SYSMENU, $WS_POPUP)) GUISetState (@SW_LOCK) GUISetBkColor(0xffffff) ;Main Logo Picture $gMainLogo = GUICtrlCreatePic(@ScriptDir & "\test.jpg",-1,-1,0,0) GUICtrlSetState(-1, $GUI_DISABLE) Thank you for your time, VJA Link to comment Share on other sites More sharing options...
Musashi Posted May 14, 2021 Share Posted May 14, 2021 (edited) 8 hours ago, VJA said: thought I better ask the geniuses. I am far from being a genius , but perhaps this will help you: #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> ; Example : path of an image that is by default provided with AutoIt : Local $sPicture = StringRegExpReplace(@AutoItExe, "(?i)AutoIt3.exe$", "") & "Examples\GUI\merlin.gif" Local $hGUI, $aPos, $idMainLogo If WinExists("Notification") Then MsgBox(0, "Exit :", "Notification Windows exists") $hGUI = GUICreate("Notification", 556, 625, Default, Default, BitOr($WS_CAPTION, $WS_SYSMENU, $WS_POPUP)) GUISetBkColor(0xFFFFFF) $aPos = WinGetPos($hGUI) $idMainLogo = GUICtrlCreatePic($sPicture, 0, 0, $aPos[2], $aPos[3]) GUISetState (@SW_SHOW) While True Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd GUIDelete($hGUI) Note : It would be helpful, if you could provide a complete script (and the graphic as well). Your current version does not even contain the required #Include 's or the "Acknowledge" button, etc. For posting code use : Edited May 15, 2021 by Musashi "In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move." Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 15, 2021 Moderators Share Posted May 15, 2021 Moved to the appropriate forum. Moderation Team Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
VJA Posted May 17, 2021 Author Share Posted May 17, 2021 Thank you so much for your reply, tried your code and the gui window opened, but with no image. Replaced "Examples\GUI\merlin.gif" with "C:\Temp\test_556x625.jpg". Current code used below and with my test image, it remains in the top left corner. I'll use the add code this time, thank you 😊 expandcollapse popup; Script Function: ; Display for GUI #include <Date.au3> #include <File.au3> #include <EditConstants.au3> #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <ComboConstants.au3> #include <ColorConstants.au3> #include <StaticConstants.au3> #include <WinAPI.au3> ; Global Variables ************************************************************************************************************************************** Global $font = "Arial" Global $gui Global $aButton Global $day Global $progname = "Test" Global $agree = 0 ; Global Variables ************************************************************************************************************************************** FileInstall('C:\Temp\test_556x625.jpg', @ScriptDir & "\test_556x625.jpg",1);Prompt Graphic If WinExists("Notification") Then Exit EndIf #Region ### START GUI section and File Install### $gui = GUICreate("Notification", 556, 625, Default, Default, BitOr($WS_CAPTION, $WS_SYSMENU, $WS_POPUP)) GUISetState (@SW_LOCK) GUISetBkColor(0xffffff) ;Main Logo Picture $gMainLogo = GUICtrlCreatePic(@ScriptDir & "\test_556x625.jpg",-1,-1,0,0) GUICtrlSetState(-1, $GUI_DISABLE) ;Agree Button $ClientSize = WinGetClientSize($gui) $agree = GUICtrlCreateButton("Acknowledge",180, 580, 185, 35) GUICtrlSetFont ($agree,10,1000,"",$font) #EndRegion ### END GUI section ### GUISetState(@SW_ENABLE) GUISetState(@SW_SHOW) WinActivate($gui) While 1 $msg = GUIGetMsg() Select Case $msg = $agree Sleep(1000) GUIDelete() Sleep(1000) $agree=1 MsgBox (0,"Notification","Thank You! Your response has been recorded.",5) Exit (5000) EndSelect WEnd Link to comment Share on other sites More sharing options...
Musashi Posted May 17, 2021 Share Posted May 17, 2021 (edited) On 5/14/2021 at 10:42 PM, VJA said: I have a gui box the same size as the jpg, but it keeps putting the jpg very tiny in the top left corner. I am still not quite aware of what you want to achieve . If the jpg. file has the size 556 x 625 (as the filename "test_556x625.jpg" suggests), then the GUI looks like this on my system : From the help for GUICtrlCreatePic : To set the picture control to the same size as the file content set width and height to 0. For testing add the following include : #include <GDIPlus.au3> and directly after the line "FileInstall ..." insert the following code : _GDIPlus_Startup () Local $hImage = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\test_556x625.jpg") If @error Then MsgBox(16, "Error", "Does the file exist?") Exit 1 EndIf MsgBox(0, "Size", "Width = " & _GDIPlus_ImageGetWidth($hImage) & @CRLF & _ "Height = " & _GDIPlus_ImageGetHeight($hImage) & @CRLF) _GDIPlus_ImageDispose ($hImage) _GDIPlus_ShutDown () What are the size specifications ? EDIT : Possibly we have a so called XY-Problem here The term "Acknowledge" indicates, that a person has to read and confirm something (maybe a text - see your first posting). To display what should be confirmed, you use the graphic. Is my assumption correct ? If Yes, then there are probably better ways, that you just don't know about yet . Edited May 17, 2021 by Musashi "In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move." Link to comment Share on other sites More sharing options...
UEZ Posted May 17, 2021 Share Posted May 17, 2021 Maybe this helps: expandcollapse popup; Script Function: ; Display for GUI #include <GDIPlus.au3> #include <Date.au3> #include <File.au3> #include <EditConstants.au3> #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <ComboConstants.au3> #include <ColorConstants.au3> #include <StaticConstants.au3> #include <WinAPI.au3> ; Global Variables ************************************************************************************************************************************** Global $font = "Arial" Global $gui Global $aButton Global $day Global $progname = "Test" Global $agree = 0 ; Global Variables ************************************************************************************************************************************** $sImage = @ScriptDir & "\test_556x625.jpg" FileInstall('C:\Temp\test_556x625.jpg', $sImage,1);Prompt Graphic _GDIPlus_Startup() $hImage = _GDIPlus_ImageLoadFromFile($sImage) $aDim = _GDIPlus_ImageGetDimension($hImage) _GDIPlus_ImageDispose($hImage) _GDIPlus_Shutdown() If WinExists("Notification") Then Exit EndIf #Region ### START GUI section and File Install### $gui = GUICreate("Notification", 556, 625, Default, Default, BitOr($WS_CAPTION, $WS_SYSMENU, $WS_POPUP)) GUISetState (@SW_LOCK) GUISetBkColor(0xffffff) ;Main Logo Picture $gMainLogo = GUICtrlCreatePic($sImage,(556-$aDim[0])/2,(625-$aDim[1])/2,$aDim[0],$aDim[1]) GUICtrlSetState(-1, $GUI_DISABLE) ;Agree Button $ClientSize = WinGetClientSize($gui) $agree = GUICtrlCreateButton("Acknowledge",180, 580, 185, 35) GUICtrlSetFont ($agree,10,1000,"",$font) #EndRegion ### END GUI section ### GUISetState(@SW_ENABLE) GUISetState(@SW_SHOW) WinActivate($gui) While 1 $msg = GUIGetMsg() Select Case $msg = $agree Sleep(1000) GUIDelete() Sleep(1000) $agree=1 MsgBox (0,"Notification","Thank You! Your response has been recorded.",5) Exit (5000) EndSelect WEnd VJA 1 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...
Musashi Posted May 17, 2021 Share Posted May 17, 2021 @VJA : One more question, before we proceed to work on a potentially less suitable solution : Your approach reminds me of a typical 'Confirm' page, as known e.g. from Installers (Setup's). There you have to enable a checkbox on the page with the License Agreement. Before this is not done, the "Continue" Button remains grayed out (deactivated). Is this what you are looking for? "In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move." Link to comment Share on other sites More sharing options...
pixelsearch Posted May 17, 2021 Share Posted May 17, 2021 7 hours ago, Musashi said: From the help for GUICtrlCreatePic : To set the picture control to the same size as the file content set width and height to 0. Hi Musashi Unfortunately this sentence is wrong since AutoIt release 3.3.14.3 as illustrated in this post. Maybe it works at your place because you're using an older AutoIt version. Sometimes I give old AutoIt versions a personalized name in my AutoIt history folder ... autoit-v3.3.10.0 (invasion of Yashied WinApiEx func).zip ... autoit-v3.3.12.0 (musashi).zip ... autoit-v3.3.14.3 (no more big WinAPI.au3).zip ... As Jpm sent the fix to Jon 9 months ago, then it still doesn't work in beta 3.3.15.3 which was released 1 year ago (re-tested just now) . Patience, it will work again one of these days. Musashi 1 Link to comment Share on other sites More sharing options...
VJA Posted May 18, 2021 Author Share Posted May 18, 2021 Awesome! Thank you everyone, added @UEZ suggestion and it worked perfectly! 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