Jump to content

[Solved] Is it possible to set Recrusive hotkey?


Recommended Posts

Is it possible to set hotkeys with additional parameters like functions?

This is what I have right now

HotKeySet("{F1}", "_find_1")

Func _find_1()
    _find_2('P727234')
EndFunc

Func _find_2($value)
;~  Find the value
EndFunc

This is what I want

HotKeySet("{F1}", "_find(P727234)")
HotKeySet("{F2}", "_find(xpx5479)")
HotKeySet("{F3}", "_find(0000000)")

Func _find($value)
;~  Find the value
EndFunc
Edited by goldenix
My Projects:[list][*]Guide - ytube step by step tut for reading memory with autoitscript + samples[*]WinHide - tool to show hide windows, Skinned With GDI+[*]Virtualdub batch job list maker - Batch Process all files with same settings[*]Exp calc - Exp calculator for online games[*]Automated Microsoft SQL Server 2000 installer[*]Image sorter helper for IrfanView - 1 click opens img & move ur mouse to close opened img[/list]
Link to comment
Share on other sites

You could use @HotKeyPressed.

HotKeySet("{ESC}","_exit")
HotKeySet("{F1}", "_find")
HotKeySet("{F2}", "_find")
HotKeySet("{F3}", "_find")

Func _find()
    If @HotKeyPressed = "{F1}" Then $value = "P727234"
    If @HotKeyPressed = "{F2}" Then $value = "xpx5479"
    If @HotKeyPressed = "{F3}" Then $value = "0000000"
    MsgBox(0, @HotKeyPressed , $value)
;~  Find the value
EndFunc

Func _exit()
    Exit
EndFunc

while 1
WEnd
GDIPlusDispose - A modified version of GDIPlus that auto disposes of its own objects before shutdown of the Dll using the same function Syntax as the original.EzMySql UDF - Use MySql Databases with autoit with syntax similar to SQLite UDF.
Link to comment
Share on other sites

I still dont like this, but this will still make my script hundreds of lines shorter, so thanx.

My Projects:[list][*]Guide - ytube step by step tut for reading memory with autoitscript + samples[*]WinHide - tool to show hide windows, Skinned With GDI+[*]Virtualdub batch job list maker - Batch Process all files with same settings[*]Exp calc - Exp calculator for online games[*]Automated Microsoft SQL Server 2000 installer[*]Image sorter helper for IrfanView - 1 click opens img & move ur mouse to close opened img[/list]
Link to comment
Share on other sites

I threw together a small UDF that will allow to do this with a syntax much like HotKeySet.

HotKeySetEx.au3

This demonstrates it's use, but it's pretty straightforeward.

#include "HotKeySetEx.au3"

Local $sTest = "This is a test string." ;some params to test with
Local $aTest[1] = ["This is a test Array"]

_HotKeySetEx("{1}","_Test()")
_HotKeySetEx("{2}","_sTest($sTest)")
_HotKeySetEx("{3}","_aTest($aTest)")

While 1
    Sleep(100)
WEnd

Func _Test()
    ConsoleWrite("Test was called!" & @CRLF)
EndFunc

Func _sTest($string)
    ConsoleWrite("Test was called with string: " & $string & "!" & @CRLF)
EndFunc

Func _aTest($array)
    ConsoleWrite("Test was called with an array. First index: " & $array[0] & "!" & @CRLF)
EndFunc

edit: I should probably change it to use Call() instead of Execute()

Edit2. I did so, but wasn't pleased with the result.

Edited by Tvern
Link to comment
Share on other sites

I threw together a small UDF that will allow to do this with a syntax much like HotKeySet.

hoo very good idea & it works nice thanx. This should really be included in the standard UDF library.

If it would be possible to add hotkeys more easily than like this it would be da hammer:

$3 = xxx

_HotKeySetEx("{F3}","_Find_('" & $3 & "'" & ")")
Edited by goldenix
My Projects:[list][*]Guide - ytube step by step tut for reading memory with autoitscript + samples[*]WinHide - tool to show hide windows, Skinned With GDI+[*]Virtualdub batch job list maker - Batch Process all files with same settings[*]Exp calc - Exp calculator for online games[*]Automated Microsoft SQL Server 2000 installer[*]Image sorter helper for IrfanView - 1 click opens img & move ur mouse to close opened img[/list]
Link to comment
Share on other sites

_HotKeySetEx("{F3}","_Find_('" & $3 & "')") is a little easier, but I get what you mean.

I don't think this syntax will be used allot as it causes the variable to be read at creation time and that value will be used whenever the hotkey is pressed.

When you pass the variable name as part of the literal string the value of the variable will be read each time the hotkey is pressed, which I figured would be the more commonly used.

I might try to cook something up that will correct the syntax when a parameter is passed like this: _HotKeySetEx("{F3}","_Find_(" & $3 & ")"), but I fear it might cause more trouble then it's worth.

My main concern at this time is that I would like to check if a function exists when creating a hotkey, but I have no idea how to do that.

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