tantrim Posted March 10, 2013 Share Posted March 10, 2013 (edited) So i've been beating my head against the wall for some hours now and can't figure this out.Im unsure on how to link a single(1) ListViewItem to a single(1) function. Although i have several functions and list items that I would like to link together. I'm attempting to use a button to do the selection but i'm not much of a programmer.I would like to link the Anhur() function to the ListItem labeled Anhur. Currently right now, when i run the program, the anhur function is running 100% of the time, but I want it to only work when its ListItem has been selected with the button. I think it could possibly be done with a GUISetOnEvent but am unsure on how to do this.btw, ive been using alot of different peoples codes trying to complete this as im not a programmer, so if you see anything that could be deleted without hindering functionality feel free to share. Thanks in Advance to anyone who helps me!!!EDIT: sorry, wasn't sure on how to add the codeexpandcollapse popup#include <GuiListBox.au3> #include <GuiListView.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <Constants.au3> Global $listview Opt("GUIOnEventMode", 1) _Main() Func _Main() $listGUI = GUICreate("easyScript", 220, 200, 100, 100, -1) GUISetOnEvent($GUI_EVENT_CLOSE, "On_Close_Main") $listview = GUICtrlCreateListView("Gods", 10, 10, 200, 150) _GUICtrlListView_SetColumnWidth($listview, 0, 190) GUICtrlCreateListViewItem("Anhur", $listview) GUICtrlCreateListViewItem("Freya", $listview) $selectGod = GUICtrlCreateButton("Select God", 75, 165, 80, 30) GUICtrlSetOnEvent(-1, "SelectItem") GUISetState() EndFunc ;==>_Main Func SelectItem() $sItem = GUICtrlRead(GUICtrlRead($listview)) MsgBox(0, "Selected Item", $sItem) EndFunc ;--------------------------------------- ; Anhur ;--------------------------------------- While 1 HotKeySet("{F1}", "Anhur") WEnd Func Anhur(); send("{1}") mouseclick("") Sleep(400) send("{2}") mouseclick("") Sleep(550) send("{4}") mouseclick("") EndFunc Func On_Close_Main() Exit EndFunc Edited March 10, 2013 by tantrim Link to comment Share on other sites More sharing options...
PhoenixXL Posted March 10, 2013 Share Posted March 10, 2013 (edited) Welcome to the Forum tantrim, Well what you are trying to achieve is simple..but what is your aim is suspicious yet.Are you trying to automate a Game ?If yes, I guess you wont receive any help here.Check the Forum Rules on the bottom right corner of this page.If not please provide your aims...Regards Edited March 10, 2013 by PhoenixXL My code: PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners. MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression. Link to comment Share on other sites More sharing options...
water Posted March 10, 2013 Share Posted March 10, 2013 By the names he used in the code snippet he provided it looks like he tries to automate a game. Let's see what the Mods say. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 10, 2013 Moderators Share Posted March 10, 2013 tantrim,Welcome to the AutoIt forum. As already suggested, please read the Forum rules (there is also a link at bottom right of each page) - particularly the bit about not discussing game automation. As this appears to be what you are doing, you will get no help here. See you soon with a legitimate question I hope. 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 Link to comment Share on other sites More sharing options...
Recommended Posts