Sign in to follow this  
Followers 0
L3G3NdKillEr

Key Counter Need Help

37 posts in this topic

I want to make a key counter. for example ( when i press 7 in my keyboard then 1 is activated for five minutes)

i want to add this on titlebar of my script


i'm very responsible, when ever something goes wrong they always say I'm responsible.Life is like an Adventure... BUT COOL GRAPHICS<====================----=LEGEND KILLER=----=========================>

Share this post


Link to post
Share on other sites



I want to make a key counter. for example ( when i press 7 in my keyboard then 1 is activated for five minutes)

i want to add this on titlebar of my script

when i pressed 7 then key pressed on titlebar equal to 1 if 7 press 2 times then keypressed equal to 2.

CODE
#include <GUIConstants.au3>

Opt("GUIOnEventMode", 1)

#Region ### START Koda GUI section ### Form=

$Form1 = GUICreate("Key pressed: ", 633, 1, 193, 342)

GUISetOnEvent($GUI_EVENT_CLOSE, "AForm1Close")

GUISetOnEvent($GUI_EVENT_MINIMIZE, "AForm1Minimize")

GUISetOnEvent($GUI_EVENT_MAXIMIZE, "AForm1Maximize")

GUISetOnEvent($GUI_EVENT_RESTORE, "AForm1Restore")

GUISetState(@SW_SHOW)

#EndRegion ### END Koda GUI section ###

While 1

Sleep(100)

WEnd

Func AForm1Close()

EndFunc

Func AForm1Maximize()

EndFunc

Func AForm1Minimize()

EndFunc

Func AForm1Restore()

EndFunc


i'm very responsible, when ever something goes wrong they always say I'm responsible.Life is like an Adventure... BUT COOL GRAPHICS<====================----=LEGEND KILLER=----=========================>

Share this post


Link to post
Share on other sites

You're still not very clear... But maybe you can use HotkeySet("7","SevenCounter") and make a function SevenCounter() that increments a variable $count by one, then use (AutoIt)WinSetTitle() to make a new window title including the $count variable.


Roses are FF0000, violets are 0000FF... All my base are belong to you.

Share this post


Link to post
Share on other sites

CODE
#include <GUIConstants.au3>

#include <math.au3>

HotKeySet("7","sevencounter")

Opt("GUIOnEventMode", 1)

#Region ### START Koda GUI section ### Form=

$Form1 = GUICreate("cal:", 633, 1, 195, 260, BitOR($WS_MINIMIZEBOX,$WS_GROUP,$WS_CLIPSIBLINGS))

GUISetOnEvent($GUI_EVENT_CLOSE, "AForm1Close")

GUISetOnEvent($GUI_EVENT_MINIMIZE, "AForm1Minimize")

GUISetOnEvent($GUI_EVENT_MAXIMIZE, "AForm1Maximize")

GUISetOnEvent($GUI_EVENT_RESTORE, "AForm1Restore")

GUISetState(@SW_SHOW)

#EndRegion ### END Koda GUI section ###

While 1

Sleep(100)

WEnd

Func sevencounter()

for $i = 1 to 10 step 1

$cal = WinSetTitle( "cal:", "", "cal:= " & $i )

Next

EndFunc

Func AForm1Close()

EndFunc

Func AForm1Maximize()

EndFunc

Func AForm1Minimize()

EndFunc

Func AForm1Restore()

EndFunc

You're still not very clear... But maybe you can use HotkeySet("7","SevenCounter") and make a function SevenCounter() that increments a variable $count by one, then use (AutoIt)WinSetTitle() to make a new window title including the $count variable.

its stop adding after 1 and not continue check this out to know my problem


i'm very responsible, when ever something goes wrong they always say I'm responsible.Life is like an Adventure... BUT COOL GRAPHICS<====================----=LEGEND KILLER=----=========================>

Share this post


Link to post
Share on other sites

Why would you use this function?

Func sevencounter()
for $i = 1 to 10 step 1
$cal = WinSetTitle( "cal:", "", "cal:= " & $i )
Next
EndFunc

This is not working.

But if you change it like:

Func sevencounter()
$i +=1
$cal = WinSetTitle( "cal:", "", "cal:= " & $i )
EndFunc

you will need to declare $i as a global variable and to initialize it

add this line somewhere on the main part of your GUI

Global $i=0

SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

Share this post


Link to post
Share on other sites

Why would you use this function?

Func sevencounter()
for $i = 1 to 10 step 1
$cal = WinSetTitle( "cal:", "", "cal:= " & $i )
Next
EndFunc

This is not working.

But if you change it like:

Func sevencounter()
$i +=1
$cal = WinSetTitle( "cal:", "", "cal:= " & $i )
EndFunc

you will need to declare $i as a global variable and to initialize it

add this line somewhere on the main part of your GUI

Global $i=0
Thanks for help :whistle:

i'm very responsible, when ever something goes wrong they always say I'm responsible.Life is like an Adventure... BUT COOL GRAPHICS<====================----=LEGEND KILLER=----=========================>

Share this post


Link to post
Share on other sites

what should i do for decrease the 7 value if 1 is pressed


i'm very responsible, when ever something goes wrong they always say I'm responsible.Life is like an Adventure... BUT COOL GRAPHICS<====================----=LEGEND KILLER=----=========================>

Share this post


Link to post
Share on other sites

what should i do for decrease the 7 value if 1 is pressed

Make another hotkey, like HotkeySet("1","sevencounterDOWN"). Then add the sevencounterDOWN() function, which should probably be about the same as the up counter function but then count down instead of up.


Roses are FF0000, violets are 0000FF... All my base are belong to you.

Share this post


Link to post
Share on other sites

CODE
#include <GUIConstants.au3>

#include <math.au3>

HotKeySet("7","sevencounter")

HotKeySet("1", "sevencounterDOWN")

Global $i = 0

Opt("GUIOnEventMode", 1)

#Region ### START Koda GUI section ### Form=

$Form1 = GUICreate("cal:=", 633, 1, 195, 260, BitOR($WS_MINIMIZEBOX,$WS_GROUP,$WS_CLIPSIBLINGS))

GUISetOnEvent($GUI_EVENT_CLOSE, "AForm1Close")

GUISetOnEvent($GUI_EVENT_MINIMIZE, "AForm1Minimize")

GUISetOnEvent($GUI_EVENT_MAXIMIZE, "AForm1Maximize")

GUISetOnEvent($GUI_EVENT_RESTORE, "AForm1Restore")

GUISetState(@SW_SHOW)

#EndRegion ### END Koda GUI section ###

While 1

Sleep(100)

WEnd

Func sevencounter()

$i +=1

$cal = WinSetTitle( "cal:", "", "cal:= " & $i )

SoundPlay( @WindowsDir & "\media\ringin.wav" )

EndFunc

Func sevencounterDOWN()

$i -=1

sleep ( 200 )

$cal = WinSetTitle( "Cal:=", "", "cal:=" & $i )

EndFunc

i've created this and its not decreses 7 value when 1 is pressed check this out to know


i'm very responsible, when ever something goes wrong they always say I'm responsible.Life is like an Adventure... BUT COOL GRAPHICS<====================----=LEGEND KILLER=----=========================>

Share this post


Link to post
Share on other sites

Try:

#include <GUIConstants.au3>

HotKeySet("7", "SevenUp")
HotKeySet("1", "SevenDown")

Opt("GUIOnEventMode", 1)

Global $i = 0

$myGUI = GUICreate("Times Pressed:")
GUISetOnEvent($GUI_EVENT_CLOSE, "Terminate")
GUISetState()

While 1
    Sleep(10)
WEnd

Func Terminate()
    Exit 0
EndFunc

Func SevenUp()
    $i += 1
    WinSetTitle("Times Pressed:", "", "Times Pressed: " & $i)
EndFunc

Func SevenDown()
    If $i > 0 Then
        $i -= 1
    Else
        $i = 0
    EndIf
    WinSetTitle("Times Pressed:", "", "Times Pressed: " & $i)
EndFunc

IE Dev ToolbarMSDN: InternetExplorer ObjectMSDN: HTML/DHTML Reference Guide[quote]It is surprising what a man can do when he has to, and how little most men will do when they don't have to. - Walter Linn[/quote]--------------------[font="Franklin Gothic Medium"]Post a reproducer with less than 100 lines of code.[/font]

Share this post


Link to post
Share on other sites

Try:

#include <GUIConstants.au3>

HotKeySet("7", "SevenUp")
HotKeySet("1", "SevenDown")

Opt("GUIOnEventMode", 1)

Global $i = 0

$myGUI = GUICreate("Times Pressed:")
GUISetOnEvent($GUI_EVENT_CLOSE, "Terminate")
GUISetState()

While 1
    Sleep(10)
WEnd

Func Terminate()
    Exit 0
EndFunc

Func SevenUp()
    $i += 1
    WinSetTitle("Times Pressed:", "", "Times Pressed: " & $i)
EndFunc

Func SevenDown()
    If $i > 0 Then
        $i -= 1
    Else
        $i = 0
    EndIf
    WinSetTitle("Times Pressed:", "", "Times Pressed: " & $i)
EndFunc
Thanks for help :whistle:

i'm very responsible, when ever something goes wrong they always say I'm responsible.Life is like an Adventure... BUT COOL GRAPHICS<====================----=LEGEND KILLER=----=========================>

Share this post


Link to post
Share on other sites

Try:

#include <GUIConstants.au3>

HotKeySet("7", "SevenUp")
HotKeySet("1", "SevenDown")

Opt("GUIOnEventMode", 1)

Global $i = 0

$myGUI = GUICreate("Times Pressed:")
GUISetOnEvent($GUI_EVENT_CLOSE, "Terminate")
GUISetState()

While 1
    Sleep(10)
WEnd

Func Terminate()
    Exit 0
EndFunc

Func SevenUp()
    $i += 1
    WinSetTitle("Times Pressed:", "", "Times Pressed: " & $i)
EndFunc

Func SevenDown()
    If $i > 0 Then
        $i -= 1
    Else
        $i = 0
    EndIf
    WinSetTitle("Times Pressed:", "", "Times Pressed: " & $i)
EndFunc
Thanks for help :whistle:

i'm very responsible, when ever something goes wrong they always say I'm responsible.Life is like an Adventure... BUT COOL GRAPHICS<====================----=LEGEND KILLER=----=========================>

Share this post


Link to post
Share on other sites

i want to disabled 1 for five minutes. if 7 pressed equal to 2 and is pressed for 1 time then disabled 1 for five minutes.

if u have any confusion tell me i will clear u my problem

CODE
#include <GUIConstants.au3>

HotKeySet("7", "SevenUp")

HotKeySet("1", "SevenDown")

Opt("GUIOnEventMode", 1)

Global $i = 0

$myGUI = GUICreate("seven pressed=", 633, 1, 195, 260, BitOR($WS_MINIMIZEBOX,$WS_GROUP,$WS_CLIPSIBLINGS))

GUISetOnEvent($GUI_EVENT_CLOSE, "Terminate")

GUISetState()

While 1

Sleep(10)

WEnd

Func Terminate()

Exit 0

EndFunc

Func SevenUp()

$i += 1

WinSetTitle("seven pressed=", "", "seven pressed= " & $i)

soundplay( @WindowsDir & "\media\ringin.wav" )

EndFunc

Func SevenDown()

If $i > 0 Then

$i -= 1

Else

$i = 0

EndIf

WinSetTitle("seven pressed=", "", "seven pressed=" & $i)

EndFunc


i'm very responsible, when ever something goes wrong they always say I'm responsible.Life is like an Adventure... BUT COOL GRAPHICS<====================----=LEGEND KILLER=----=========================>

Share this post


Link to post
Share on other sites

If seven is pressed 2 times, then sleep for 5 minutes is what I understood....something like:

Func SevenUp()
    If $i = 2 Then
        Sleep(5000*60)
    EndIf
    ;probably a good idea to disable your hotkeys here, then re-enable them
    $i += 1
    WinSetTitle("Times Pressed:", "", "Times Pressed: " & $i)
EndFunc

IE Dev ToolbarMSDN: InternetExplorer ObjectMSDN: HTML/DHTML Reference Guide[quote]It is surprising what a man can do when he has to, and how little most men will do when they don't have to. - Walter Linn[/quote]--------------------[font="Franklin Gothic Medium"]Post a reproducer with less than 100 lines of code.[/font]

Share this post


Link to post
Share on other sites

thanx but u never completely understood

i am using 2 hotkeys 7 and 1. if 7 is pressed then 1 send "enter" and then disabled for five minutes.


i'm very responsible, when ever something goes wrong they always say I'm responsible.Life is like an Adventure... BUT COOL GRAPHICS<====================----=LEGEND KILLER=----=========================>

Share this post


Link to post
Share on other sites

You couldn't figure that one out on your own? Work thtrough this, hopefully after that you'll understand it. It's the same thing you've been doing all along, just with a different outcome.

Func SevenUp()
    If $i = 2 Then
        HotKeySet("1", "SendEnter")
        Sleep(5000*60)
    EndIf
    ;probably a good idea to disable your hotkeys here, then re-enable them
    $i += 1
    WinSetTitle("Times Pressed:", "", "Times Pressed: " & $i)
EndFunc

Func SendEnter()
    Send("{ENTER}")
EndFunc

IE Dev ToolbarMSDN: InternetExplorer ObjectMSDN: HTML/DHTML Reference Guide[quote]It is surprising what a man can do when he has to, and how little most men will do when they don't have to. - Walter Linn[/quote]--------------------[font="Franklin Gothic Medium"]Post a reproducer with less than 100 lines of code.[/font]

Share this post


Link to post
Share on other sites

THANX DUDE!


i'm very responsible, when ever something goes wrong they always say I'm responsible.Life is like an Adventure... BUT COOL GRAPHICS<====================----=LEGEND KILLER=----=========================>

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