Jump to content
Sign in to follow this  
tantrim

HELP ME!!! Need Help With Linking Function To a GUICtrlCreateListViewItem

Recommended Posts

tantrim

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 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
Edited by tantrim

Share this post


Link to post
Share on other sites
PhoenixXL

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 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.

Share this post


Link to post
Share on other sites
water

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 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
Melba23

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. :naughty:

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._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this  

×