Jump to content

ListView Help


Snipz
 Share

Recommended Posts

Im trying to get it if the command is highlighted it will run a func. Heres my code.

$listview2 = GuiCtrlCreateList("Ridged", 50, 35, 115, 45)
$listview = GUICtrlSetData($listview2,"Normal")

GuiSetState()

While 1
If _IsPressed('1b') = 1 Then Exit

$msg = GUIGetMsg()

Select
Case $msg = $listview
Normal()

Case $msg = $listview2
Ridged()

EndSelect
Wend
Once my friend told me that he had found Jesus. I thought to myself, "Woohoo, we're rich!" It turns out he meant something different.Sometimes I just like to lay in my bed and look up at the stars and wonder..where the hell did my roof go?
Link to comment
Share on other sites

Im trying to get it if the command is highlighted it will run a func. Heres my code.

$listview2 = GuiCtrlCreateList("Ridged", 50, 35, 115, 45)
$listview = GUICtrlSetData($listview2,"Normal")

GuiSetState()

While 1
If _IsPressed('1b') = 1 Then Exit

$msg = GUIGetMsg()

Select
Case $msg = $listview
Normal()

Case $msg = $listview2
Ridged()

EndSelect
Wend

You have to read the control in your message loop (before the Case statements) to find out which item is selected. GUICtrlRead will do the trick. For listview controls, it returns an index number corresponding to the item.

For example:

$item = GUICtrlRead ($listview2)

Then, in your Case statements:

Case $item = 0

;Do this thing or function()

Case $item = 1

;Do this other thing or function()

Hope that helps.

(Yet Another) ExcelCOM UDF"A human being should be able to change a diaper, plan an invasion, butcher a hog, conn a ship, design a building, write a sonnet, balance accounts, build a wall, set a bone, comfort the dying, take orders, give orders, cooperate, act alone, solve equations, analyze a new problem, pitch manure, program a computer, cook a tasty meal, fight efficiently, die gallantly...[indent]...specialization is for insects." - R. A. Heinlein[/indent]
Link to comment
Share on other sites

Forget th pm I sent you thats wrong. Take a look at this. Its not working but it should be.

#include <GuiConstants.au3>

GuiCreate("Anti-Recoil", 200, 60, 100, 200, $DS_MODALFRAME, $WS_EX_TOOLWINDOW)

$Slider = GuiCtrlCreateSlider(20, 0, 160, 50)

$item = GUICtrlRead ($Slider)

GuiSetState()
While 1

If _IsPressed('1b') = 1 Then Exit

Select
Case $Item = 1

If _IsPressed('01') = 1 Then
            $MousePos = MouseGetPos( )
            MouseMove( $MousePos[0], $MousePos[1] + 1, 100)
        EndIf
  Sleep(10)

Case $Item = 2

If _IsPressed('01') = 1 Then
            $MousePos = MouseGetPos( )
            MouseMove( $MousePos[0], $MousePos[1] + 2, 100)
        EndIf
  Sleep(10)

Case $Item = 3

If _IsPressed('01') = 1 Then
            $MousePos = MouseGetPos( )
            MouseMove( $MousePos[0], $MousePos[1] + 3, 100)
        EndIf
  Sleep(10)

Case $Item = 4

If _IsPressed('01') = 1 Then
            $MousePos = MouseGetPos( )
            MouseMove( $MousePos[0], $MousePos[1] + 4, 100)
        EndIf
  Sleep(10)

Case $Item = 5

If _IsPressed('01') = 1 Then
            $MousePos = MouseGetPos( )
            MouseMove( $MousePos[0], $MousePos[1] + 5, 100)
        EndIf
  Sleep(10)

Case $Item = 6

If _IsPressed('01') = 1 Then
            $MousePos = MouseGetPos( )
            MouseMove( $MousePos[0], $MousePos[1] + 6, 100)
        EndIf
  Sleep(10)

Case $Item = 7

If _IsPressed('01') = 1 Then
            $MousePos = MouseGetPos( )
            MouseMove( $MousePos[0], $MousePos[1] + 7, 100)
        EndIf
  Sleep(10)

Case $Item = 8

If _IsPressed('01') = 1 Then
            $MousePos = MouseGetPos( )
            MouseMove( $MousePos[0], $MousePos[1] + 8, 100)
        EndIf
  Sleep(10)

Case $Item = 9

If _IsPressed('01') = 1 Then
            $MousePos = MouseGetPos( )
            MouseMove( $MousePos[0], $MousePos[1] + 9, 100)
        EndIf
  Sleep(10)

Case $Item = 10

If _IsPressed('01') = 1 Then
            $MousePos = MouseGetPos( )
            MouseMove( $MousePos[0], $MousePos[1] + 10, 100)
        EndIf
  Sleep(10)

EndSelect
WEnd
Exit

Func _IsPressed($hexKey)
   Local $aR, $bO

  $hexKey = '0x' & $hexKey
  $aR = DllCall("user32", "int", "GetAsyncKeyState", "int", $hexKey)
  If Not @error And BitAND($aR[0], 0x8000) = 0x8000 Then
     $bO = 1
  Else
     $bO = 0
  EndIf

  Return $bO
EndFunc ;==>_IsPressed
Once my friend told me that he had found Jesus. I thought to myself, "Woohoo, we're rich!" It turns out he meant something different.Sometimes I just like to lay in my bed and look up at the stars and wonder..where the hell did my roof go?
Link to comment
Share on other sites

  • Moderators

Try putting the $item = GuiCtrlRead($slider) inside the loop, because the value will never change from it's initial state outside the loop.

#include <GuiConstants.au3>

GuiCreate("Anti-Recoil", 200, 60, 100, 200, $DS_MODALFRAME, $WS_EX_TOOLWINDOW)

$Slider = GuiCtrlCreateSlider(20, 0, 160, 50)

GuiSetState()
While 1

$item = GUICtrlRead ($Slider)

If _IsPressed('1b') = 1 Then Exit

Select
Case $Item = 1

If _IsPressed('01') = 1 Then
            $MousePos = MouseGetPos( )
            MouseMove( $MousePos[0], $MousePos[1] + 1, 100)
        EndIf
  Sleep(10)

Case $Item = 2

If _IsPressed('01') = 1 Then
            $MousePos = MouseGetPos( )
            MouseMove( $MousePos[0], $MousePos[1] + 2, 100)
        EndIf
  Sleep(10)

Case $Item = 3

If _IsPressed('01') = 1 Then
            $MousePos = MouseGetPos( )
            MouseMove( $MousePos[0], $MousePos[1] + 3, 100)
        EndIf
  Sleep(10)

Case $Item = 4

If _IsPressed('01') = 1 Then
            $MousePos = MouseGetPos( )
            MouseMove( $MousePos[0], $MousePos[1] + 4, 100)
        EndIf
  Sleep(10)

Case $Item = 5

If _IsPressed('01') = 1 Then
            $MousePos = MouseGetPos( )
            MouseMove( $MousePos[0], $MousePos[1] + 5, 100)
        EndIf
  Sleep(10)

Case $Item = 6

If _IsPressed('01') = 1 Then
            $MousePos = MouseGetPos( )
            MouseMove( $MousePos[0], $MousePos[1] + 6, 100)
        EndIf
  Sleep(10)

Case $Item = 7

If _IsPressed('01') = 1 Then
            $MousePos = MouseGetPos( )
            MouseMove( $MousePos[0], $MousePos[1] + 7, 100)
        EndIf
  Sleep(10)

Case $Item = 8

If _IsPressed('01') = 1 Then
            $MousePos = MouseGetPos( )
            MouseMove( $MousePos[0], $MousePos[1] + 8, 100)
        EndIf
  Sleep(10)

Case $Item = 9

If _IsPressed('01') = 1 Then
            $MousePos = MouseGetPos( )
            MouseMove( $MousePos[0], $MousePos[1] + 9, 100)
        EndIf
  Sleep(10)

Case $Item = 10

If _IsPressed('01') = 1 Then
            $MousePos = MouseGetPos( )
            MouseMove( $MousePos[0], $MousePos[1] + 10, 100)
        EndIf
  Sleep(10)

EndSelect
WEnd
Exit

Func _IsPressed($hexKey)
   Local $aR, $bO

  $hexKey = '0x' & $hexKey
  $aR = DllCall("user32", "int", "GetAsyncKeyState", "int", $hexKey)
  If Not @error And BitAND($aR[0], 0x8000) = 0x8000 Then
     $bO = 1
  Else
     $bO = 0
  EndIf

  Return $bO
EndFunc;==>_IsPressed

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

That only works on first tick.

Once my friend told me that he had found Jesus. I thought to myself, "Woohoo, we're rich!" It turns out he meant something different.Sometimes I just like to lay in my bed and look up at the stars and wonder..where the hell did my roof go?
Link to comment
Share on other sites

  • Moderators

I guess I'm not understanding what your asking for specifically, but I've re-read your post and this should give you what you want, just replace the 'MsgBox()'s' with your function calls.

#include <GuiConstants.au3>
Dim $MoveToFindFunction
GuiCreate("Anti-Recoil", 200, 60, 100, 200, $DS_MODALFRAME, $WS_EX_TOOLWINDOW)
$Slider = GuiCtrlCreateSlider(20, 0, 160, 50)
GUICtrlSetLimit(-1,10)
GuiSetState()
While 1
    If _IsPressed('1b') = 1 Then Exit
    If _IsPressed('01') Then
        While _IsPressed('01') = 1
            Sleep(10)
            $MoveToFindFunction = 1
            $item = GUICtrlRead ($Slider)
        WEnd
        While $MoveToFindFunction = 1
        Select
            Case $Item = 1
                MsgBox(0, '1', '$Item = 1')
                $MoveToFindFunction = 0
            Case $Item = 2
                MsgBox(0, '2', '$Item = 2')
                $MoveToFindFunction = 0
            Case $Item = 3
                MsgBox(0, '3', '$Item = 3')
                $MoveToFindFunction = 0
            Case $Item = 4
                MsgBox(0, '4', '$Item = 5')
                $MoveToFindFunction = 0
            Case $Item = 5
                MsgBox(0, '5', '$Item = 5')
                $MoveToFindFunction = 0
            Case $Item = 6
                MsgBox(0, '6', '$Item = 6')
                $MoveToFindFunction = 0
            Case $Item = 7
                MsgBox(0, '7', '$Item = 7')
                $MoveToFindFunction = 0
            Case $Item = 8
                MsgBox(0, '8', '$Item = 8')
                $MoveToFindFunction = 0
            Case $Item = 9
                MsgBox(0, '9', '$Item = 9')
                $MoveToFindFunction = 0
            Case $Item = 10
                MsgBox(0, '10', '$Item = 10')
                $MoveToFindFunction = 0
        EndSelect
        Sleep(10)
    WEnd
    EndIf
    Sleep(10)
WEnd
Exit
Func _IsPressed($hexKey)
    Local $aR, $bO
    $hexKey = '0x' & $hexKey
    $aR = DllCall("user32", "int", "GetAsyncKeyState", "int", $hexKey)
    If Not @error And BitAND($aR[0], 0x8000) = 0x8000 Then
        $bO = 1
    Else
        $bO = 0
    EndIf
    Return $bO
EndFunc  ;==>_IsPressed

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

  • Moderators

Would be nice to know if this worked for you seeing as you've seen it and all. :P

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

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