Jump to content

Gui button click timed


Recommended Posts

Hi 'Coffee'

Just an idea for you if you don't want to have an extra button..

I also know you just might be trying to figure this out "just because" so I'm not ignoring your request. Perhaps the overlooked GUIGetCursorInfo() commands could be some help in getting your cursor info for you particularly

with option [4]of the array, great for action to occur on mouseover, right click, left click etc, when combined with "if true AND $var[4] = 3 etc..

anyway this particular example is not what you "wanted" but a suggestion thrown your way

Thanks Coffee, I'll go away and evaluate what you've said, as well as Smoke_N's last post, but as you see above, a solution has been implemented ... mostly thanks to Smoke_N, but thanks to all others too!

ps..been years since I posted on here, haha I'm probably easily forgotten, so hello.

Welcome back, and you shouldn't stay away so long, this is a great place to be - educational, interesting and even highly amusing at times, not to mention - sometimes frustrating. THAT'S LIFE! Edited by TheSaint

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Link to comment
Share on other sites

Kudos once again to Smoke_N

Your latest reworking worked flawlessly!

Extra Kudos to Coffee, who pointed the way to what is possibly the perfect solution ... perfect in that it does exactly what I originally wanted (without a dll call), but I kinda like the button text visually updating while the mouse button is still depressed.

Who'd have thought, that what I needed was in the 'GUIGetCursorInfo' command? I must admit that it's not one I've looked at very much ... hardly ever in fact ... I mean why would I think to look at something cursor related. I think they should mention this in the help file (in the button section), as it does exactly what I wanted - sends an event on the primary down, which can be intercepted.

Coffee seemed to focus on the right-click aspect of this command, but I found it worked exactly how I wanted with the left-click. Here then without any further ado, is the solution I was always looking for - very simple buts works perfect -

#include <GuiConstants.au3>

Dim $Button_11, $Input_rn, $Label_rn, $Updown_rn
Dim $begin, $cnt, $Dialog, $diff, $height, $inifle, $new, $width

$inifle = @ScriptDir & "\Template.ini"

;If Not IsDeclared('WS_CLIPSIBLINGS') Then Global $WS_CLIPSIBLINGS = 0x04000000

$Dialog = $WS_OVERLAPPED + $WS_CAPTION + $WS_SYSMENU + $WS_VISIBLE + $WS_CLIPSIBLINGS
$width = 430
$height = 450

$STemp = GuiCreate("Script Templates v2.0", $width, $height, _
            (@DesktopWidth-$width)/2, (@DesktopHeight-$height-30)/2 , $Dialog + $WS_MINIMIZEBOX)

$Input_rn = GUICtrlCreateInput("0", 135, 370, 40, 20)
$Updown_rn = GUICtrlCreateUpdown($Input_rn)
GUICtrlSetLimit($Updown_rn, 99, 0)
$Label_rn = GUICtrlCreateLabel("lines", 180, 373, 30, 20)
$Button_11 = GUICtrlCreateButton("", 210, 370, 20, 20)

$num = IniRead($inifle, "Line Count", "default", "")
If $num = "" Then
    $num = "11"
    IniWrite($inifle, "Line Count", "default", $num)
EndIf
GUICtrlSetData($Button_11, $num)

GuiSetState(@SW_SHOW, $STemp)
While 1
    $msg = GuiGetMsg()
    $checkID = GUIGetCursorInfo($STemp)
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case $msg = $Button_11
        $diff = TimerDiff($begin)
        If $diff > 1500 Then; more than 1.5 seconds
            $new =GUICtrlRead($Input_rn)
            IniWrite($inifle, "Line Count", "default", $new)
            GUICtrlSetData($Button_11, $new)
        ElseIf $diff < 1500 Then; less than 1.5 seconds
            $num = IniRead($inifle, "Line Count", "default", "")
            GUICtrlSetData($Input_rn, $num)
        EndIf
        $cnt = ""
       ;MsgBox(0, "Time Mouse Down", $diff)
    Case $checkID[2] = 1 And $checkID[4] = "6"
        If $cnt = "" Then $begin = TimerInit()
        $cnt = 1
    EndSelect
WEnd
Exit

Works in the following manner -

1) quick click (not keeping the mouse button down), the default value as seen on the button (from the ini file) is returned to the input/updown box.

2) sustained click (holding/depressing for more than 1.5 seconds), the value in the input/updown box, is returned as the new default, and saved to the ini file, and also updates the button text!

They usually say simple is best, and I must admit that, that is always what I try to aim for!

THREE CHEERS FOR COFFEE ... and a couple to Smoke_N ... thanks guys!

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Link to comment
Share on other sites

For those who like to know!

jpm has added some information in GUIGetMsg about GUIGetCursorInfo in 3.1.1.126

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

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