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!!!
Code:
#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