Sign in to follow this  
Followers 0
Xait

Storing multiple functions within variables

16 posts in this topic

Hi,

Is there a way I can store functions within a variable?

I have a script that will move the mouse 1px up, down, left or right with the arrow keys and 2px up, down, left or right with the numpad. I want to add a graphic interface to the script with radio buttons to choose what one you use (so I can eventually make all of them use just the arrow keys).

My problem is that whenever I try to insert the series of functions into the 'Case $Radio1' part it returns an error saying functions can't be put inside them. Is there a way I can put the functions within a variable and use that?

Thanks

My script so far:

HotKeySet("{UP}", "moveup")
HotKeySet("{RIGHT}", "moveright")
HotKeySet("{DOWN}", "movedown")
HotKeySet("{LEFT}", "moveleft")
HotKeySet("{NUMPAD4}", "moveleft2")
HotKeySet("{NUMPAD6}", "moveright2")
HotKeySet("{NUMPAD8}", "moveup2")
HotKeySet("{NUMPAD2}", "movedown2")

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1_1 = GUICreate("Mouse Mover", 173, 172, 192, 124)
$Radio1 = GUICtrlCreateRadio("Move 1pixel", 16, 40, 137, 33)
$Radio2 = GUICtrlCreateRadio("Move 2pixel", 16, 80, 137, 33)
$Radio3 = GUICtrlCreateRadio("Move 5pixel", 16, 120, 137, 33)
$Label1 = GUICtrlCreateLabel("Mouse Mover", 16, 16, 140, 23)
GUICtrlSetFont($Label1, 12, 400, 0, "Broadway")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Form1_1
        Case $Form1_1
        Case $Form1_1
        Case $Form1_1
        Case $Radio1
        Case $Radio2
        Case $Radio3
        Case $Label1
    EndSwitch
WEnd



While 1 = 1
    Sleep(1000)
WEnd


    Func movedown()
        $pos = MouseGetPos()
        MouseMove($pos[0], $pos[1] + 1, 1)
    EndFunc   ;==>movedown

    Func moveright()
        $pos = MouseGetPos()
        MouseMove($pos[0] + 1, $pos[1], 1)
    EndFunc   ;==>moveright

    Func moveleft()
        $pos = MouseGetPos()
        MouseMove($pos[0] - 1, $pos[1], 1)
    EndFunc   ;==>moveleft

    Func moveup()
        $pos = MouseGetPos()
        MouseMove($pos[0], $pos[1] - 1, 1)
    EndFunc   ;==>moveup



    Func movedown2()
        $pos = MouseGetPos()
        MouseMove($pos[0], $pos[1] + 2, 1)
    EndFunc   ;==>movedown2

    Func moveright2()
        $pos = MouseGetPos()
        MouseMove($pos[0] + 2, $pos[1], 1)
    EndFunc   ;==>moveright2

    Func moveleft2()
        $pos = MouseGetPos()
        MouseMove($pos[0] - 2, $pos[1], 1)
    EndFunc   ;==>moveleft2

    Func moveup2()
        $pos = MouseGetPos()
        MouseMove($pos[0], $pos[1] - 2, 1)
    EndFunc

Share this post


Link to post
Share on other sites



Xait,

I think you are getting confused between "function names" and "function definitions".

Function definitions are the code bewteen the Func...EndFunc lines and they must be on their own within the script and not within anything else such as Switch structures or other function definitions.

Function names are the name immediately following the Func commands and are used activate the function code.

It sounds as though you were putting the Definitions in the Switch structure and not the Names. Look at this example:

#include <GUIConstantsEx.au3>

$hGUI = GUICreate("Test", 500, 500)
$hButton = GUICtrlCreateButton("Test", 10, 10, 80, 30)
GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $hButton
            function_name()
    EndSwitch
WEnd

; This is a function definition
Func function_name()  ; << this is the function name
    MsgBox(0, "Hit", "You have activated the function")
EndFunc

I hope that is clear. :)

I have amended your script slightly to offer a few more pointers:

1. Use of a group so that you can only select 1 radio at a time (you can easily remove it if you do not want to limit the selction in this way)

2. The second While...WEnd has gone - it served no purpose!

3. The remaining While...WEnd has been reduced in size. You only really want to know when a radio is selected to move the mouse - or the [X] to exit. When a radio is clicked, the script checks to see which one is now selected and (for the moment) displays a MsgBox to tell you. As explained above, all you need to do is list the names of the functions you want to activate in place of the MsgBox command.

Take a look:

HotKeySet("{UP}", "moveup")
HotKeySet("{RIGHT}", "moveright")
HotKeySet("{DOWN}", "movedown")
HotKeySet("{LEFT}", "moveleft")
HotKeySet("{NUMPAD4}", "moveleft2")
HotKeySet("{NUMPAD6}", "moveright2")
HotKeySet("{NUMPAD8}", "moveup2")
HotKeySet("{NUMPAD2}", "movedown2")

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

#Region ### START Koda GUI section ### Form=
$Form1_1 = GUICreate("Mouse Mover", 173, 172, 192, 124)
GUIStartGroup($Form1_1)
$Radio1 = GUICtrlCreateRadio("Move 1pixel", 16, 40, 137, 33)
ConsoleWrite($Radio1 & @CRLF)
$Radio2 = GUICtrlCreateRadio("Move 2pixel", 16, 80, 137, 33)
$Radio3 = GUICtrlCreateRadio("Move 5pixel", 16, 120, 137, 33)
ConsoleWrite($Radio3 & @CRLF)
$Label1 = GUICtrlCreateLabel("Mouse Mover", 16, 16, 140, 23)
GUICtrlSetFont($Label1, 12, 400, 0, "Broadway")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Radio1, $Radio2, $Radio3
            If GUICtrlRead($Radio1) = 1 Then
                MsgBox(0, "Move", "1 pixel")
            ElseIf GUICtrlRead($Radio2) = 1 Then
                MsgBox(0, "Move", "2 pixels")
            ElseIf GUICtrlRead($Radio3) = 1 Then
                MsgBox(0, "Move", "5 pixels")
            EndIf
    EndSwitch
WEnd

    Func movedown()
        $pos = MouseGetPos()
        MouseMove($pos[0], $pos[1] + 1, 1)
    EndFunc   ;==>movedown

    Func moveright()
        $pos = MouseGetPos()
        MouseMove($pos[0] + 1, $pos[1], 1)
    EndFunc   ;==>moveright

    Func moveleft()
        $pos = MouseGetPos()
        MouseMove($pos[0] - 1, $pos[1], 1)
    EndFunc   ;==>moveleft

    Func moveup()
        $pos = MouseGetPos()
        MouseMove($pos[0], $pos[1] - 1, 1)
    EndFunc   ;==>moveup

    Func movedown2()
        $pos = MouseGetPos()
        MouseMove($pos[0], $pos[1] + 2, 1)
    EndFunc   ;==>movedown2

    Func moveright2()
        $pos = MouseGetPos()
        MouseMove($pos[0] + 2, $pos[1], 1)
    EndFunc   ;==>moveright2

    Func moveleft2()
        $pos = MouseGetPos()
        MouseMove($pos[0] - 2, $pos[1], 1)
    EndFunc   ;==>moveleft2

    Func moveup2()
        $pos = MouseGetPos()
        MouseMove($pos[0], $pos[1] - 2, 1)
    EndFunc

Please ask if anything is unclear - or if I have got it entirely wrong! ;)

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

Thanks Melba23. that cleared a few problems up (including ones I was dreading running into next.

I have only been using AutoIt for about 3days so your help is much appreciated!

Wez.

Share this post


Link to post
Share on other sites

Xait,

That is what the forum is for! Good luck. :)

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

#5 ·  Posted (edited)

Thanks for your help earlier.

Is there a way I can set the same hot key to different functions?

I have tried:

HotkeySet("{LEFT}", "moveleft")

HotKeySet("{LEFT}", "moveleft2")

that only seems to make it choose one or the other though. I want to use just the arrow keys no for all the different buttons (1px, 2px and 5px). any suggestions.

I have this in my radio button Case:

Case $Radio1, $Radio2, $Radio3
            If GUICtrlRead($Radio1) = 1 Then
                movedown()
                moveright()
                moveup()
                moveleft()
            ElseIf GUICtrlRead($Radio2) = 1 Then
                movedown2()
                moveright2()
                moveup2()
                moveleft2()
            ElseIf GUICtrlRead($Radio3) = 1 Then
                MsgBox(0, "Move", "5 pixels")

Thanks for your help! =]

PS. sorry for the PM. didn't realise it was frowned upon.

Edited by Xait

Share this post


Link to post
Share on other sites

Xait,

You need to use parameters with the functions. Take a look at this:

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

Global $iIncrement = 1 ; Set the default value of the MouseMove increment

HotKeySet("{UP}", "moveup")
HotKeySet("{RIGHT}", "moveright")
HotKeySet("{DOWN}", "movedown")
HotKeySet("{LEFT}", "moveleft")

#Region ### START Koda GUI section ### Form=
$Form1_1 = GUICreate("Mouse Mover", 173, 172, 192, 124)
GUIStartGroup($Form1_1)
$Radio1 = GUICtrlCreateRadio("Move 1pixel", 16, 40, 137, 33)
ConsoleWrite($Radio1 & @CRLF)
$Radio2 = GUICtrlCreateRadio("Move 2pixel", 16, 80, 137, 33)
$Radio3 = GUICtrlCreateRadio("Move 5pixel", 16, 120, 137, 33)
ConsoleWrite($Radio3 & @CRLF)
$Label1 = GUICtrlCreateLabel("Mouse Mover", 16, 16, 140, 23)
GUICtrlSetFont($Label1, 12, 400, 0, "Broadway")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Radio1, $Radio2, $Radio3
            If GUICtrlRead($Radio1) = 1 Then
                $iIncrement = 1 ; Set the new increment value
                movedown(1)     ; Call the function and pass the value as a parameter
                moveright(1)    ; You could also use moveright($iIncrement) if you wanted to exercise your typing finger :-)
                moveup(1)
                moveleft(1)
            ElseIf GUICtrlRead($Radio2) = 1 Then
                $iIncrement = 2
                movedown(2)
                moveright(2)
                moveup(2)
                moveleft(2)
            ElseIf GUICtrlRead($Radio3) = 1 Then
                $iIncrement = 5
                movedown(5)
                moveright(5)
                moveup(5)
                moveleft(5)
            EndIf
    EndSwitch
WEnd

    Func movedown($iIncrement) ; Tell the function to expect a parameter - it does NOT have to be the same name
        $pos = MouseGetPos()
        MouseMove($pos[0], $pos[1] + $iIncrement, 1)  ; use the parameter to make the function behave differently!
    EndFunc   ;==>movedown

    Func moveright($iIncrement)
        $pos = MouseGetPos()
        MouseMove($pos[0] + $iIncrement, $pos[1], 1)
    EndFunc   ;==>moveright

    Func moveleft($iIncrement)
        $pos = MouseGetPos()
        MouseMove($pos[0] - $iIncrement, $pos[1], 1)
    EndFunc   ;==>moveleft

    Func moveup()
        $pos = MouseGetPos($iIncrement)
        MouseMove($pos[0], $pos[1] - $iIncrement, 1)
    EndFunc   ;==>moveup

I hope that is all clear - please ask if not. :)

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

Again, thank you very much =]

Your close to becoming a genius in my books :)

Wez

Share this post


Link to post
Share on other sites

I get an error when trying to run the script you last linked. ' ERROR: movedown() called by a previous line with 0 arg(s). Min = 1. First previous line calling this Func is 10.

Func movedown($iIncrement) ; Tell the function to expect a parameter - it does NOT have to be the same name'

I find it a little hard to understand as the line it points to is HotKeySet("{DOWN}", "movedown")

it also does this for moveup, moveleft and move right

any ideas?

thanks

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

HotKeys can't call functions with parameters (unless you use some nifty udfs found on the forum). Also, mouseup() needed a paremeter. Here is the code:

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

Global $iIncrement = 1 ; Set the default value of the MouseMove increment

#Region ### START Koda GUI section ### Form=
$Form1_1 = GUICreate("Mouse Mover", 173, 172, 192, 124)
GUIStartGroup($Form1_1)
$Radio1 = GUICtrlCreateRadio("Move 1pixel", 16, 40, 137, 33)
ConsoleWrite($Radio1 & @CRLF)
$Radio2 = GUICtrlCreateRadio("Move 2pixel", 16, 80, 137, 33)
$Radio3 = GUICtrlCreateRadio("Move 5pixel", 16, 120, 137, 33)
ConsoleWrite($Radio3 & @CRLF)
$Label1 = GUICtrlCreateLabel("Mouse Mover", 16, 16, 140, 23)
GUICtrlSetFont($Label1, 12, 400, 0, "Broadway")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Radio1, $Radio2, $Radio3
            If GUICtrlRead($Radio1) = 1 Then
                $iIncrement = 1 ; Set the new increment value
                movedown(1) ; Call the function and pass the value as a parameter
                moveright(1) ; You could also use moveright($iIncrement) if you wanted to exercise your typing finger :-)
                moveup(1)
                moveleft(1)
            ElseIf GUICtrlRead($Radio2) = 1 Then
                $iIncrement = 2
                movedown(2)
                moveright(2)
                moveup(2)
                moveleft(2)
            ElseIf GUICtrlRead($Radio3) = 1 Then
                $iIncrement = 5
                movedown(5)
                moveright(5)
                moveup(5)
                moveleft(5)
            EndIf
    EndSwitch
WEnd

Func movedown($iIncrement) ; Tell the function to expect a parameter - it does NOT have to be the same name
    $pos = MouseGetPos()
    MouseMove($pos[0], $pos[1] + $iIncrement, 1) ; use the parameter to make the function behave differently!
EndFunc ;==>movedown

Func moveright($iIncrement)
    $pos = MouseGetPos()
    MouseMove($pos[0] + $iIncrement, $pos[1], 1)
EndFunc ;==>moveright

Func moveleft($iIncrement)
    $pos = MouseGetPos()
    MouseMove($pos[0] - $iIncrement, $pos[1], 1)
EndFunc ;==>moveleft

Func moveup($iIncrement)
    $pos = MouseGetPos($iIncrement)
    MouseMove($pos[0], $pos[1] - $iIncrement, 1)
EndFunc ;==>moveup
Edited by dantay9

[font="Verdana"] [size="2"]"[/size][/font]Failure is not an option -- it comes packaged with Windows"[font="Verdana"][size="2"] Gecko Web Browser[/size][/font][font="Verdana"][size="2"], [/size][/font][font="Verdana"][size="2"]Yahtzee![/size][/font][font="Verdana"][size="2"], Toolbar Launcher (like RocketDock)[/size][/font][font="Verdana"][size="2"]Internet Blocker, Simple Calculator, Local Weather, Easy GDI+ GUI [/size][/font][font="Verdana"][size="2"]Triangle Solver, TCP File Transfer, [/size][/font][font="Verdana"][size="2"]Valuater's Autoit Wrappers[/size][/font][font="Verdana"][size="3"][size="2"][size="2"]OOP In AutoIt[/size][/size][/size][/font][font="Verdana"][size="2"][size="1"]Using Windows XP SP3, 1GB RAM, AMD Athlon Processor @ 2.1 GHzCheck me out at gadgets.freehostrocket.com[/size][/size][/font]

Share this post


Link to post
Share on other sites

I still receive the same error (although the help is no less appreciated!)

This is the full error if it helps more:

C:\AutoItScript\Test.au3(56,108) : ERROR: movedown() called by a previous line with 0 arg(s). Min = 1. First previous line calling this Func is 9.
Func movedown($iIncrement) ; Tell the function to expect a parameter - it does NOT have to be the same name
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\AutoItScript\Test.au3(61,28) : ERROR: moveright() called by a previous line with 0 arg(s). Min = 1. First previous line calling this Func is 8.
Func moveright($iIncrement)
~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\AutoItScript\Test.au3(66,27) : ERROR: moveleft() called by a previous line with 0 arg(s). Min = 1. First previous line calling this Func is 10.
Func moveleft($iIncrement)
~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\AutoItScript\Test.au3(71,25) : ERROR: moveup() called by a previous line with 0 arg(s). Min = 1. First previous line calling this Func is 7.
Func moveup($iIncrement)
~~~~~~~~~~~~~~~~~~~~~~~~^
C:\AutoItScript\Test.au3 - 4 error(s), 0 warning(s)

And in response to to your post Dantay9, I don't believe my hot keys have parameters on them (although I could be wrong). Also thanks for pointing out the error with mouseup()

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

Xait,

My apologies, I had completely forgotten about the HotKeys - age, you know! ;)

The solution is to use a default parameter ($iIncrement = 1) so that the HotKeys do not have to use one. If there is no parameter, AutoIt uses the default - but we have already cleverly set it when a Radio is pressed. :)

Take a look at this:

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

Global $iIncrement = 1

HotKeySet("{UP}", "moveup")
HotKeySet("{RIGHT}", "moveright")
HotKeySet("{DOWN}", "movedown")
HotKeySet("{LEFT}", "moveleft")

#Region ### START Koda GUI section ### Form=
$Form1_1 = GUICreate("Mouse Mover", 173, 172, 192, 124)
GUIStartGroup($Form1_1)
$Radio1 = GUICtrlCreateRadio("Move 1pixel", 16, 40, 137, 33)
$Radio2 = GUICtrlCreateRadio("Move 2pixel", 16, 80, 137, 33)
$Radio3 = GUICtrlCreateRadio("Move 5pixel", 16, 120, 137, 33)
$Label1 = GUICtrlCreateLabel("Mouse Mover", 16, 16, 140, 23)
GUICtrlSetFont($Label1, 12, 400, 0, "Broadway")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Radio1, $Radio2, $Radio3
            If GUICtrlRead($Radio1) = 1 Then
                $iIncrement = 1
                movedown(1)
                moveright(1)
                moveup(1)
                moveleft(1)
            ElseIf GUICtrlRead($Radio2) = 1 Then
                $iIncrement = 25
                movedown(25)
                moveright(25)
                moveup(25)
                moveleft(25)
            ElseIf GUICtrlRead($Radio3) = 1 Then
                $iIncrement = 50
                movedown(50)
                moveright(50)
                moveup(50)
                moveleft(50)
            EndIf
    EndSwitch
WEnd

    Func movedown($iIncrement = 1)
        $pos = MouseGetPos()
        MouseMove($pos[0], $pos[1] + $iIncrement, 1)
    EndFunc   ;==>movedown

    Func moveright($iIncrement = 1)
        $pos = MouseGetPos()
        MouseMove($pos[0] + $iIncrement, $pos[1], 1)
    EndFunc   ;==>moveright

    Func moveleft($iIncrement = 1)
        $pos = MouseGetPos()
        MouseMove($pos[0] - $iIncrement, $pos[1], 1)
    EndFunc   ;==>moveleft

    Func moveup($iIncrement = 1)
        $pos = MouseGetPos()
        MouseMove($pos[0], $pos[1] - $iIncrement, 1)
    EndFunc   ;==>moveup

I have increased the move bounds to make it obvious that we are using the selected increment - it is easy to reset them.

Apologies again. I hope this one works to your satisfaction - I have tested it more thoroughly this time. B)

M23

Edited by Melba23

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

Apologies again. I hope this one works to your satisfaction - I have tested it more thoroughly this time. :)

M23

Lol, that's OK mate, your help is great. I'll test it in the morning :-) thanks

Wez

Share this post


Link to post
Share on other sites

Hi again ;-)

Is there a way I can toggle the left mouse button (so i can push a key, lets say numpad5 and it puts the left mouse button down until i push it again.)

I have been trying for hours and can't figure it out. Would it use 'If' somehow to determine whether MouseDown("Left") is active

thanks for help.

Share this post


Link to post
Share on other sites

Xait,

Dog eaten your Help file? What about MouseDown, MouseUp and HotKeySet? I am sure I saw them in there somewhere :)

Using "m" as the action key

HotKeySet("m", "Mouse_Toggle")

$fMouse_State = False

#include <GUIConstantsEx.au3>

$hGUI = GUICreate("Test", 500, 500)

$hLabel = GUICtrlCreateLabel("", 10, 10, 100, 20)

GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
    GUICtrlSetData($hLabel, $fMouse_State)
WEnd

Func Mouse_Toggle()
    If $fMouse_State = False Then
        MouseDown("left")
        $fMouse_State = True
    Else
        MouseUp("left")
        $fMouse_State = False
    EndIf
EndFunc

You do not need the GUI, of course - it is just there to show the toggle.

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

Xait,

Dog eaten your Help file? What about MouseDown, MouseUp and HotKeySet? I am sure I saw them in there somewhere :)

Using "m" as the action key

HotKeySet("m", "Mouse_Toggle")

$fMouse_State = False

#include <GUIConstantsEx.au3>

$hGUI = GUICreate("Test", 500, 500)

$hLabel = GUICtrlCreateLabel("", 10, 10, 100, 20)

GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
    GUICtrlSetData($hLabel, $fMouse_State)
WEnd

Func Mouse_Toggle()
    If $fMouse_State = False Then
        MouseDown("left")
        $fMouse_State = True
    Else
        MouseUp("left")
        $fMouse_State = False
    EndIf
EndFunc

You do not need the GUI, of course - it is just there to show the toggle.

M23

I did spend time looking through and tried several things as well. but I was stuck on how to get the MouseUp to to work only when the button is pushed s second time. Thank you for your time spent helping me

Share this post


Link to post
Share on other sites

Xait,

That is why we come here! :)

Good luck with your coding.

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

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
Sign in to follow this  
Followers 0