Phaser Posted September 28, 2011 Posted September 28, 2011 (edited) Hi Guys Is there a way to call a image file and put it next to a drop down combo the user has to match the image with something in the drop down, example an image of a dog would match the word dog in the dropdown then click ok so another image can load. I have looked through the help file and example folder, I see how to call the image into a gui but not into a message box, please point me in the right direction, the images are in the same folder as the script. After clicking ok I am writing the image name and answer from dropdown to an .ini file. Is there a way? Edited September 28, 2011 by Phaser
Moderators Melba23 Posted September 28, 2011 Moderators Posted September 28, 2011 Phaser,I see how to call the image into a gui but not into a message boxSo why not use a GUI? What does a MsgBox have that a user-drawn GUI does not? 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
Phaser Posted September 28, 2011 Author Posted September 28, 2011 Hi Melba, thanks for looking in, I have an array of images to run through, so was contemplating doing it in a do statement $i = 0 Do Here I want to load the image by getting its name from the array key[$i] Now I want to load the image into some sort of display next to a drop down box containing a set of words with an OK button Now take the image name AND the selected answer and write it to the ini file $i = $i+1 Until $i = 10 When above is complete the script will continue, need to sort the above so I can carry on. I didn't know if a GUI would be ok for this task so will give it a try, thanks again
Phaser Posted September 28, 2011 Author Posted September 28, 2011 (edited) Hi Guys Heres what I have so far, it loads fine but doesn't write to the ini file when clicked #include <GUIConstantsEx.au3> #include <Array.au3> HotKeySet("{ESC}", "killit") Opt("GUIOnEventMode", 1) Local $images[3]=["dog","cat","bird"],$image $i = 0 Do GuiCreate("Match Image", 300, 100) GuiCtrlCreatePic($images[$i] & ".jpg",2,2, 169,68) $image = $images[$i] $answer = GUICtrlCreateCombo("", 200, 20, 70, 20) GUICtrlSetData($answer, "1|2|3|4|5","1") $accept = GUICtrlCreateButton("OK", 50, 70, 60) GUICtrlSetOnEvent($accept, "writetoini") GuiSetState() writetoini() $i = $i+1 Until $i = 3 While 1 Sleep(1000) WEnd Func writetoini() IniWrite("info.ini", "Answers", $image, $answer) EndFunc Func killit() Exit EndFunc When the OK button is clicked I want it to load the next image, when the last image is loaded and OK clicked I would like it to close the GUI Any ideas? Edited September 28, 2011 by Phaser
Moderators Melba23 Posted September 29, 2011 Moderators Posted September 29, 2011 Phaser, Do not create your GUI several times - just update the controls like this: #include <GUIConstantsEx.au3> #include <ComboConstants.au3> HotKeySet("{ESC}", "killit") Opt("GUIOnEventMode", 1) Local $images[3] = ["dog", "cat", "bird"], $image GUICreate("Match Image", 300, 100) $hLabel = GUICtrlCreateLabel($images[0], 2, 2, 169, 68) ; You would use GUICtrlCreatePic here <<<<<<<<<<<<<<<<<<<<< $image = $images[0] $answer = GUICtrlCreateCombo("", 200, 20, 70, 20, $CBS_DROPDOWNLIST) ; Makes it read only GUICtrlSetData($answer, "1|2|3|4|5", "1") $accept = GUICtrlCreateButton("OK", 50, 70, 60) GUICtrlSetOnEvent($accept, "writetoini") GUISetState() $iCount = 0 While 1 Sleep(10) WEnd Func writetoini() IniWrite("info.ini", "Answers", $image, GUICtrlRead($answer)) $iCount += 1 If $iCount = 3 Then Exit GUICtrlSetData($hLabel, $images[$iCount]) ; You would use GUICtrlSetImage here <<<<<<<<<<<<<<<<<<<<< $image = $images[$iCount] EndFunc ;==>writetoini Func killit() Exit EndFunc ;==>killit I have used a label rather than a Pic control - you can see where you need to change functions (look for the <<<<<<< lines). Please ask if there is anything you do not understand. 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
Phaser Posted September 29, 2011 Author Posted September 29, 2011 (edited) Hi Melba, thanks for helping OK it almost works, as you may have worked out its not really for dogs n cats, I am trying to get my database tool working on win7, I have hundreds of codes to capture so have started to create an installer that should work on any pc. My XP version doesn't work on win7 as for some reason win7 changes the colours so I decided to use chexksum values and capture the number images then, with this bit of code, assign the checksum to the number image. Heres what I have #include <GUIConstantsEx.au3> #include <ComboConstants.au3> HotKeySet("{ESC}", "killit") Opt("GUIOnEventMode", 1) Local $checksums[5] = [73998694,735085934,1312511217,2002807561,2278841389], $checksum GUICreate("Match Image", 300, 100) $hLabel = GUICtrlCreatePic($checksums[0] & ".jpg", 2, 2, 169, 68) $checksum = $checksums[0] $number = GUICtrlCreateCombo("", 200, 20, 70, 20, $CBS_DROPDOWNLIST) ; Makes it read only GUICtrlSetData($number, "1|2|3|4|5", "1") $accept = GUICtrlCreateButton("OK", 50, 70, 60) GUICtrlSetOnEvent($accept, "writetoini") GUISetState() $iCount = 0 While 1 Sleep(10) WEnd Func writetoini() IniWrite("info.ini", "Numbers", $checksum, GUICtrlRead($number)) $iCount += 1 If $iCount = 5 Then Exit GUICtrlSetImage($hLabel, $checksums[$iCount]) $checksum = $checksums[$iCount] EndFunc ;==>writetoini Func killit() Exit EndFunc ;==>killit It almost works , it loads the first image then sends the data on clicking OK but, it doesn't load the next image visually but it has loaded the next checksum. I changed the bits you mentioned, please advise, the 12345 is only for testing purposes. EDIT I think I see the problem, is it this line GUICtrlSetImage($hLabel, $checksums[$iCount]) Needs to be GUICtrlSetImage($hLabel,$checksums[$iCount] & ".jpg") Yes bingo, that was the problem, thanks again for the help Edited September 29, 2011 by Phaser
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