adz89 Posted February 18, 2012 Posted February 18, 2012 Right, I've been racking my brain for a little while about this now, I've created a GUI sample for a design project in uni, however I can't get the pic function to work. We are designing a screen that will show time, date and some events etc. The code is below, and its the two GUICtrlCreatePic function calls that are the issue. They don't do anything, at all! expandcollapse popup#cs This is a script to run and display a GUI for EG-M62 group project It will call a window that will show the funtionality desired for the PC interaction of our product #ce #include <GUIConstantsEx.au3> #include <StaticConstants.au3> $today= @YEAR & "/" & @MON & "/" & @MDAY buildGUI() while 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $close $close_response = MsgBox(1,"Warning","Close without saving?") Select Case $close_response = 1 ExitLoop EndSelect Case $msg = $button progress("Saving") $ok_response = MsgBox(64,"Complete", "Please reinsert USB into the base of the light") Select Case $ok_response = 1 ExitLoop EndSelect Case $msg = $fact_reset MsgBox(48,"Warning","Pressing ok will reset all values to default, and erase any stored events") progress("Resetting all data") MsgBox(64,"Completed","Reset completed") Case $msg = $update MsgBox(64,"Update","About to update the calendar files") progress("Updating; please wait") Case $msg = $exitfilemenu $close_response = MsgBox(1,"Warning","Close without saving?") Select Case $close_response = 1 ExitLoop EndSelect Case $msg = $manualedit Run("notepad.exe") Case $msg = $softupdate progress("Updating Software") Case $msg = $aboutdisp MsgBox(64,"About","LiteTawe Configuration Software; Version 0.1 BETA") Case $msg = $saveevent MsgBox(64,"Success","Event Saved") EndSelect WEnd func buildGUI() Global $button, $close, $fact_reset, $update, $exitfilemenu, $manualedit, $softupdate, $aboutdisp, $selecteddate, $eventname, $iconselect, $saveevent $m=700 $n=600 GUICreate("Display Control",$m,$n) GUISetState(@SW_SHOW) $filemenu = GUICtrlCreateMenu("&File") $advancedmenu = GUICtrlCreateMenu("&Advanced") $aboutmenu = GUICtrlCreateMenu("&About") $exitfilemenu = GUICtrlCreateMenuItem("Exit", $filemenu) $manualedit = GUICtrlCreateMenuItem("Manual Edit",$advancedmenu) $softupdate = GUICtrlCreateMenuItem("Update Software",$aboutmenu) $aboutdisp = GUICtrlCreateMenuItem("About",$aboutmenu) $button = GUICtrlCreateButton("Ok", $m-166, $n-80, 75, 23) $close = GUICtrlCreateButton("Close", $m-85, $n-80, 75, 23) $fact_reset = GUICtrlCreateButton("Factory Reset", $m-85,$n-50,75,23) $update = GUICtrlCreateButton("Update", $m-166,$n-50,75,23) GUICtrlCreateLabel("Clock format set-up", $m-136,10) $12hour = GUICtrlCreateRadio("12 Hour",$m-126,30) $24hour = GUICtrlCreateRadio("24 Hour",$m-126,50) $digital = GUICtrlCreateCheckbox("Digital",$m-126,70) $analogue = GUICtrlCreateCheckbox("Analogue",$m-126,90) GUICtrlCreateLabel("Add events to calendar",10,10) $selecteddate = GUICtrlCreateMonthCal($today,10,30,230,165) $eventname = GUICtrlCreateInput("",250,40,250,20) GUICtrlCreateLabel("Event Name",260,20,100,20) GUICtrlCreateLabel("Choose Icon",260,70,100,20) $iconselect = GUICtrlCreateButton("...",270,90,35,23) $annual = GUICtrlCreateCheckbox("Annual Event",315,90) $saveevent = GUICtrlCreateButton("Save Event",315,120,75,23) GUICtrlSetState($digital,$GUI_CHECKED) GUICtrlSetState($annual,$GUI_CHECKED) GUICtrlSetState($12hour,$GUI_CHECKED) GUICtrlCreatePic(@WorkingDir & "...\GUI\Screen.jpg",10,270,100,100) GUICtrlCreatePic(@WorkingDir & "...\GUI\Info.jpg",$m-110,$n-113,100,100) EndFunc func progress($textstring) ProgressOn("Progress", $textstring, "Working...") For $i = 0 To 100 ProgressSet($i) Sleep(5) Next ProgressSet(100, "Done!") Sleep(500) ProgressOff() EndFunc Self confessed noob...
Moderators Melba23 Posted February 18, 2012 Moderators Posted February 18, 2012 adz89,Are you sure you have a valid path in those 2 statements? @WorkingDir defaults to the script folder and does not have a final "\" - so your path is currently "Script_Folder...\GUI\Info.jpg". Does not look very likely to work to me. When I put a valid path in those lines I get the images displayed - try doing the same. M23  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 Â
AdmiralAlkex Posted February 19, 2012 Posted February 19, 2012 @adz89 Why are you using @WorkingDir anyway? Do you know what a working directory is? You probably want @ScriptDir .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface
adz89 Posted February 19, 2012 Author Posted February 19, 2012 (edited) @adz89 Why are you using @WorkingDir anyway? Do you know what a working directory is? You probably want @ScriptDir Well I thought that would have been the way to go about it, I've come from a MATLAB programming background, so I'm having a bit of difficulty trying to get the syntax right. I've adjusted the script to now readGUICtrlCreatePic(@ScriptDir & "GUIScreen.jpg",10,270,100,100) GUICtrlCreatePic(@ScriptDir & "GUIInfo.jpg",$m-110,$n-113,100,100) but it still doesn't work... Edited February 19, 2012 by adz89 Self confessed noob...
AlmarM Posted February 20, 2012 Posted February 20, 2012 The only thing I can say about this is, are you sure those are valid paths?@ScriptDir returns the path your AU3 script is ran from. Minesweeper A minesweeper game created in autoit, source available. _Mouse_UDF An UDF for registering functions to mouse events, made in pure autoit. 2D Hitbox Editor A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes.
adz89 Posted February 20, 2012 Author Posted February 20, 2012 The only thing I can say about this is, are you sure those are valid paths?@ScriptDir returns the path your AU3 script is ran from.Well I've created the GUI folder within the folder that the script is, and of course the correct file name/extension Self confessed noob...
Moderators Melba23 Posted February 20, 2012 Moderators Posted February 20, 2012 adz89,Just to be sure that you are using the correct paths, try running FileExists with the same strings as you use in the script and see if that returns 1. That will tell you if the script is looking in the right place. M23 adz89 1  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 Â
adz89 Posted February 20, 2012 Author Posted February 20, 2012 adz89, Just to be sure that you are using the correct paths, try running FileExists with the same strings as you use in the script and see if that returns 1. That will tell you if the script is looking in the right place. M23 Well I added this; $check = FileExists(@ScriptDir & "GUIScreen.jpg") If $check = 1 Then MsgBox(0,"Success","File Exists") ElseIf $check = 0 Then MsgBox(0,"Fail","File not found") EndIf and it said that the file exists. Self confessed noob...
Moderators Melba23 Posted February 20, 2012 Moderators Posted February 20, 2012 adz89,And yet using those same strings with GUICtrlCreatePic fails? Try creating a GUI with only those 2 image controls within it and see if you can get them to work in that case. M23  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 Â
adz89 Posted February 20, 2012 Author Posted February 20, 2012 adz89,And yet using those same strings with GUICtrlCreatePic fails? Try creating a GUI with only those 2 image controls within it and see if you can get them to work in that case. M23Ok will do, I'll let you know in due course Self confessed noob...
adz89 Posted February 20, 2012 Author Posted February 20, 2012 Ok, well still nothing happening... Here is the code I used; #include <GUIConstantsEx.au3> buildGUI() while 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop EndSelect WEnd func buildGUI() $m=700 $n=600 GUICreate("Display Control",$m,$n) GUISetState(@SW_SHOW) GUICtrlCreatePic(@ScriptDir & "GUIScreen.jpg",10,270,100,100) GUICtrlCreatePic(@ScriptDir & "GUIInfo.jpg",$m-110,$n-113,100,100) EndFunc Self confessed noob...
Moderators Melba23 Posted February 20, 2012 Moderators Posted February 20, 2012 adz89, I created the same folder structure as you and my images showed up without problem using your code - so I have no idea what is going on. Really clutching at straws here, but I take it the images do actually have some content that you can see against the GUI background? Do they show up in other apps such as Paint? Have you tried using other images in their place? M23  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 Â
adz89 Posted February 21, 2012 Author Posted February 21, 2012 adz89,I created the same folder structure as you and my images showed up without problem using your code - so I have no idea what is going on. Really clutching at straws here, but I take it the images do actually have some content that you can see against the GUI background? Do they show up in other apps such as Paint? Have you tried using other images in their place? M23Well I'm out at the moment, but I'll try other images later, but the images can be open in picture viewer, and are both .jpg's...I'll let you know how it goes with other images. Self confessed noob...
adz89 Posted February 21, 2012 Author Posted February 21, 2012 Ok, I got it working, not sure what the problem was though. I renamed the non-working pic from screen to disp_ex and left it as a jpg, and resaved the jpg file to be a bmp... All working now though! Thanks for the help guys, if anyone's interested I'll post the working, final script later! Self confessed noob...
Moderators Melba23 Posted February 21, 2012 Moderators Posted February 21, 2012 adz89, Glad you got it working despite my ineffective help. M23  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 Â
adz89 Posted February 21, 2012 Author Posted February 21, 2012 adz89,Glad you got it working despite my ineffective help. M23It was the help that was ineffective, it was my programming skills! Self confessed noob...
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