Jump to content

This site uses cookies. By continuing to browse the site you are agreeing to our use of cookies. Find out more here. X
X


Photo

Using One Hotkey Multiple Times


  • Please log in to reply
17 replies to this topic

#1 Xenobiologist

Xenobiologist

    Xx Code~Mega xX

  • MVPs
  • 4,833 posts

Posted 05 May 2006 - 07:16 PM

Hi,

I don't know whether this is the right place to put such an easy script, but maybe some people need something like that one day. :)

A friend of mine asked me, how to use one hotkey to call different funcs by hitting the key different times.

(The func put() is just to show, that different funcs are called. )

So here it is:
AutoIt         
HotKeySet("a", "pressed") Dim $i = 0, $PushTime = 1000 While 1     Sleep(100) WEnd Func pressed()     $i += 1     Sleep($PushTime)     Switch $i         Case 1             put(1)         Case 2             put(2)         Case 3             put(3)         Case 4             Exit (0)     EndSwitch     $i = 0 EndFunc   ;==>pressed Func put($y)     MsgBox(0, "Func called: ", "Nr: " & $y) EndFunc   ;==>put


So long,

Mega

Edited by th.meger, 13 July 2006 - 06:03 PM.

Scripts & functions Organize Includes Let Scite organize the include files *new

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times








#2 Valuater

Valuater

    www.PayFreeWireless.com

  • MVPs
  • 11,199 posts

Posted 05 May 2006 - 07:48 PM

Actually i didn't understand at first... i would press ( slowly) and kep getting a message box with "1"

but, then i realized you press the key 1 to 4 times within the $PushTime/sleep and the function is called with the corresponding # of 1 to 3... 4 exits

I have never used hotkeyset() like this

Good demo.... th.meger

8)

Posted Image

Clic The Pic!!!


#3 RazerM

RazerM

    cowinkeedenky - coincidence?

  • Active Members
  • PipPipPipPipPipPip
  • 1,246 posts

Posted 05 May 2006 - 07:53 PM

same here valuater. Interesting use of hotkeyset.
My Programs:AInstall - Create a standalone installer for your programUnit Converter - Converts Length, Area, Volume, Weight, Temperature and Pressure to different unitsBinary Clock - Hours, minutes and seconds have 10 columns each to display timeAutoIt Editor - Code Editor with Syntax Highlighting.Laserix Editor & Player - Create, Edit and Play Laserix LevelsLyric Syncer - Create and use Synchronised Lyrics.Connect 4 - 2 Player Connect 4 Game (Local or Online!, Formatted Chat!!)MD5, SHA-1, SHA-256, Tiger and Whirlpool Hash Finder - Dictionary and Brute Force FindCool Text Client - Create Rendered ImageMy UDF's:GUI Enhance - Enhance your GUIs visually.IDEA File Encryption - Encrypt and decrypt files easily! File Rename - Rename files easilyRC4 Text Encryption - Encrypt text using the RC4 AlgorithmPrime Number - Check if a number is primeString Remove - remove lots of strings at onceProgress Bar - made easySound UDF - Play, Pause, Resume, Seek and Stop.

#4 slightly_abnormal

slightly_abnormal

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 513 posts

Posted 05 May 2006 - 07:56 PM

same here valuater. Interesting use of hotkeyset.



yeah.. cool.

#5 Xenobiologist

Xenobiologist

    Xx Code~Mega xX

  • MVPs
  • 4,833 posts

Posted 05 May 2006 - 08:06 PM

Hi,

thanks. It was kind of crackbrained. Firstly, I thought I have to take the time between hitting the hotkey but then I tried to create the buffer with the sleep command and it worked.

So long,

Mega

Scripts & functions Organize Includes Let Scite organize the include files *new

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times


#6 JSThePatriot

JSThePatriot

    carpe diem. vita brevis.

  • MVPs
  • 3,690 posts

Posted 05 May 2006 - 09:06 PM

Shows another way of thinking outside the box. I was like "hrm how is he going to accomplish this"...once I saw the variable $PushTime and its location in the Sleep I knew it was the amount of times pressed.

I like it. I think it could be a useful script.

JS
AutoIt LinksFile-String Hash Plugin Updated! 04-02-08ComputerGetInfo UDF's Updated! 11-23-06External LinksVortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

#7 Xenobiologist

Xenobiologist

    Xx Code~Mega xX

  • MVPs
  • 4,833 posts

Posted 05 May 2006 - 10:38 PM

Hi,

that's so crazy. I tried to create some useful scripts like (see my sig) and I think there might be some people out there who uses them. :(
But no SmOke_N, garfrost, Valuater, BigDod, JSThePatriot and so on replied. :)

But posting this little script ... :D

Nevertheless, I'll keep on running. I love this forum!

So long,

Mega

Edited by th.meger, 05 May 2006 - 11:34 PM.

Scripts & functions Organize Includes Let Scite organize the include files *new

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times


#8 JSThePatriot

JSThePatriot

    carpe diem. vita brevis.

  • MVPs
  • 3,690 posts

Posted 06 May 2006 - 05:51 PM

Hi,

that's so crazy. I tried to create some useful scripts like (see my sig) and I think there might be some people out there who uses them. :(
But no SmOke_N, garfrost, Valuater, BigDod, JSThePatriot and so on replied. :)

But posting this little script ... :D

Nevertheless, I'll keep on running. I love this forum!

So long,

Mega


I am in and out of the forums...many of your programs look good. I dont always have the time to check them out. I do appreciate the value you place on my opinion.

Lata,
JS
AutoIt LinksFile-String Hash Plugin Updated! 04-02-08ComputerGetInfo UDF's Updated! 11-23-06External LinksVortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

#9 Cue

Cue

    Wayfarer

  • Active Members
  • Pip
  • 84 posts

Posted 29 September 2006 - 11:42 PM

Is this not a better way of doing it. this way you will not have to wait 1 second if you only pressed it once and you can keep going for as many presses as you like.


AutoIt         
HotKeySet("a", "pressed") Dim $i = 0, $PushTime = 200 While 1     Sleep(100) WEnd Func pressed()     $i += 1         Do           $g=$i         Sleep($PushTime)             Until $g==$i         Switch $i         Case 1             put(1)         Case 2             put(2)         Case 3             put(3)         Case 4             Exit (0)     EndSwitch     $i = 0     EndFunc   Func put($y)     MsgBox(0, "Func called: ", "Nr: " & $y) EndFunc

Edited by Cue, 29 September 2006 - 11:55 PM.


#10 RazerM

RazerM

    cowinkeedenky - coincidence?

  • Active Members
  • PipPipPipPipPipPip
  • 1,246 posts

Posted 30 September 2006 - 08:48 AM

That works brilliantly Cue! It is much better without the wait
My Programs:AInstall - Create a standalone installer for your programUnit Converter - Converts Length, Area, Volume, Weight, Temperature and Pressure to different unitsBinary Clock - Hours, minutes and seconds have 10 columns each to display timeAutoIt Editor - Code Editor with Syntax Highlighting.Laserix Editor & Player - Create, Edit and Play Laserix LevelsLyric Syncer - Create and use Synchronised Lyrics.Connect 4 - 2 Player Connect 4 Game (Local or Online!, Formatted Chat!!)MD5, SHA-1, SHA-256, Tiger and Whirlpool Hash Finder - Dictionary and Brute Force FindCool Text Client - Create Rendered ImageMy UDF's:GUI Enhance - Enhance your GUIs visually.IDEA File Encryption - Encrypt and decrypt files easily! File Rename - Rename files easilyRC4 Text Encryption - Encrypt text using the RC4 AlgorithmPrime Number - Check if a number is primeString Remove - remove lots of strings at onceProgress Bar - made easySound UDF - Play, Pause, Resume, Seek and Stop.

#11 Xenobiologist

Xenobiologist

    Xx Code~Mega xX

  • MVPs
  • 4,833 posts

Posted 30 September 2006 - 04:19 PM

That works brilliantly Cue! It is much better without the wait

Hi,

what is better at the func from Cue? :)
Nice idea, but I still like my demo :P

AutoIt         
HotKeySet("1", "pressed") HotKeySet("2", "pressed1") Dim $i = 0, $PushTime = 1000, $begin = 0 While 1     Sleep(100) WEnd Func pressed()     $begin = TimerInit()     $i += 1     Do         $g = $i         Sleep($PushTime)     Until $g == $i     Switch $i         Case 1             put(1)         Case 2             put(2)         Case 3             put(3)         Case 4             Exit (0)     EndSwitch     $i = 0 EndFunc   ;==>pressed Func pressed1()     $begin = TimerInit()     $i += 1     Sleep($PushTime)     Switch $i         Case 1             put1(1)         Case 2             put1(2)         Case 3             put1(3)         Case 4             Exit (0)     EndSwitch     $i = 0 EndFunc   ;==>pressed1 Func put($y)     ConsoleWrite("Nr: " & $y & " Cue : " & Round(TimerDiff($begin), 4) & @LF)     ;MsgBox(0, "Func called: ", "Nr: " & $y) EndFunc   ;==>put Func put1($y)     ConsoleWrite("Nr: " & $y & " Mega: " & Round(TimerDiff($begin), 4) & @LF)     ;MsgBox(0, "Func called: ", "Nr: " & $y) EndFunc   ;==>put1


So long,

Mega

Scripts & functions Organize Includes Let Scite organize the include files *new

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times


#12 RazerM

RazerM

    cowinkeedenky - coincidence?

  • Active Members
  • PipPipPipPipPipPip
  • 1,246 posts

Posted 30 September 2006 - 04:34 PM

When i tested them together Cues worked better because if i pressed the hotkey 3 times fastly it would always pop up saying "you pressed 3 times" but yours would sometimes say "you pressed 2 times" then "you pressed 1 times"
My Programs:AInstall - Create a standalone installer for your programUnit Converter - Converts Length, Area, Volume, Weight, Temperature and Pressure to different unitsBinary Clock - Hours, minutes and seconds have 10 columns each to display timeAutoIt Editor - Code Editor with Syntax Highlighting.Laserix Editor & Player - Create, Edit and Play Laserix LevelsLyric Syncer - Create and use Synchronised Lyrics.Connect 4 - 2 Player Connect 4 Game (Local or Online!, Formatted Chat!!)MD5, SHA-1, SHA-256, Tiger and Whirlpool Hash Finder - Dictionary and Brute Force FindCool Text Client - Create Rendered ImageMy UDF's:GUI Enhance - Enhance your GUIs visually.IDEA File Encryption - Encrypt and decrypt files easily! File Rename - Rename files easilyRC4 Text Encryption - Encrypt text using the RC4 AlgorithmPrime Number - Check if a number is primeString Remove - remove lots of strings at onceProgress Bar - made easySound UDF - Play, Pause, Resume, Seek and Stop.

#13 Xenobiologist

Xenobiologist

    Xx Code~Mega xX

  • MVPs
  • 4,833 posts

Posted 30 September 2006 - 04:41 PM

When i tested them together Cues worked better because if i pressed the hotkey 3 times fastly it would always pop up saying "you pressed 3 times" but yours would sometimes say "you pressed 2 times" then "you pressed 1 times"


Hi,

I see, no problem for me there. :) Both worked fine.

So long,

Mega

Scripts & functions Organize Includes Let Scite organize the include files *new

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times


#14 Cue

Cue

    Wayfarer

  • Active Members
  • Pip
  • 84 posts

Posted 30 September 2006 - 11:32 PM

Thanks RazerM.
th.meger i did not mean to say that your function is written badly but i thought it would just be better to wait for a certain time between consecutive keys than wait 1 second for any amount of keypresses.

why did you write code to compare the two?

Edit: [ Your code for comparing the two will always give the same or a longer time for pressed() since you have used $PushTime with a value of 1000 for both functions]

Edit: [mistake on last edit]

Edited by Cue, 04 October 2006 - 04:30 AM.


#15 icadea

icadea

    Prodigy

  • Active Members
  • PipPipPip
  • 160 posts

Posted 02 March 2008 - 10:18 AM

thanks. this is great. I could make software for disabled people using this code.

thanks
  • Cue likes this

#16 WolfWorld

WolfWorld

    Mr.Terminator

  • Active Members
  • PipPipPipPipPipPip
  • 646 posts

Posted 02 March 2008 - 12:32 PM

This is not just n easy script but it also show us that if hotkey call a function and the function is not finish and hotkey is pressed again it will exit the last function and start the new function

#17 James

James

    Universalist

  • MVPs
  • 10,223 posts

Posted 02 March 2008 - 02:22 PM

Woah, someone brought up a two year old topic, brill! ¬_¬

#18 Achilles

Achilles

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 2,897 posts

Posted 02 March 2008 - 08:09 PM

Nice work... it's original, even though it was two years ago, I didn't realize that...




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users