Jump to content

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


tantrim
 Share

Recommended Posts

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
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

  • Moderators

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 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

 

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...