Jump to content
Sign in to follow this  
tamir

HotKeySet - some questions

Recommended Posts

tamir

i have 2 questions about HotKeySet:

1) if i want it to do a function like func($var_a, $var_:idiot:, how i aim the HotKeySet to it? i can only type the function's name

2) is it possible to do hotkey for t AND s? coz if i type HotKeySet("ts", "") it will work for pressing "s"

Edited by tamir

Share this post


Link to post
Share on other sites
Einzeinbleth

Func Func_Name ($var_a, $var_:idiot:

;code goes here

EndFunc

IT IS IN HELP FILE ! TRY

start-programs-AutoIt v3-AutoIt help file

you will found almost everything INSTANTLY

Edited by Einzeinbleth

Share this post


Link to post
Share on other sites
tamir

1) i know how to make a function.... i asked how do i call to a function with variables with HotKeySet.

2) i looked in the help file but couldn't find something...

Share this post


Link to post
Share on other sites
Einzeinbleth

oh, sorry mi mistake :D

hmzzzzz i tryed and my code doesnt work :lol::idiot: i cant help

HotKeySet("a", "FuncName('test title', 'test text')")

func FuncName($value_a, $value_b)

msgbox(0, $value_a, $value_b)
endfunc

while (1)
sleep(100)
wend

i think that in part: HotKeySet("a", "FuncName('test title', 'test text')"), the 'test title' and 'test text' will always be constant, so try to use something like

HotKeySet("a", "FuncName")

func FuncName()
$value_a='test title'
$value_b='test text'
msgbox(0, $value_a, $value_b)
endfunc

while (1)
sleep(100)
wend
Edited by Einzeinbleth

Share this post


Link to post
Share on other sites
themax90

Try HotKeySet("t" & "s", FUNC) or

HotKeySet("t", FUNC)

HotKeySet("s", FUNC)

Func Func()

;Code here

EndFunc

Share this post


Link to post
Share on other sites
tamir

ehh....

as i already said, i know how to make a function, but when i have this function:

Func func($var)

MsgBox(0, "", $var)

EndFunc

and i want to make a hotkey for it, i need to specifiy the $var, but i cant write HotKeySet("s", "func(text)") coz i need to write only the name of the func.

so what can i do?

Share this post


Link to post
Share on other sites
themax90

I TOLD YOU.

HOTKEYSET("t" & "s", FUNC)

READ IT PLEASE.

Share this post


Link to post
Share on other sites
Einzeinbleth

I TOLD YOU.

HOTKEYSET("t" & "s", FUNC)

READ IT PLEASE.

<{POST_SNAPBACK}>

He was talking about something like

HotKeySet("key", "funcname($var)")

Try to use normal variables :idiot: them should work normally. Or maybe post rest of your code, so peoples can help in another way... ?

Share this post


Link to post
Share on other sites
tamir

????

ok, say i have a function like this:

Func func($var)

MsgBox(0, "", $var)

EndFunc

if i write func("text") it will display a msgbox with the word "text".

now, i want to make these hotkeys:

ctrl+a - write "abc" = func("abc")

ctrl+b - write "def" = func("def")

so how i do it with HotKeySet?

Share this post


Link to post
Share on other sites
Valik

If "t" & "s" == "ts" Then MsgBox(4096,"","DOH!")

Lar.

<{POST_SNAPBACK}>

Dumbass would of been my message choice, Larry, but to each their own, I guess. :idiot:

Share this post


Link to post
Share on other sites
Insolence

Tamir you can't use parameters in a HotKeySet function callback.

You can ONLY use the function, sorry. It works that way for a lot of things, you just have to be clever and figure a way around it, I suppose.


"I thoroughly disapprove of duels. If a man should challenge me, I would take him kindly and forgivingly by the hand and lead him to a quiet place and kill him." - Mark TwainPatient: "It hurts when I do $var_"Doctor: "Don't do $var_" - Lar.

Share this post


Link to post
Share on other sites
tamir

I TOLD YOU.

HOTKEYSET("t" & "s", FUNC)

READ IT PLEASE.

<{POST_SNAPBACK}>

it aint working....

if i press "s" FUNC is activate

Share this post


Link to post
Share on other sites
therks

Wow. So much misinformation in this thread, it's almost mind boggling.

Not until post #13 did any real information make it's way through.

Er, wait, post #5 does have one thing going for it.

If you want to have a function work on two different keys (ie 't' and 's') then do two seperate calls to HotKeySet, as post #5 suggested.

HotKeySet("t", "FuncName")
HotKeySet("s", "FuncName")

If people actually tried their methods before posting them, it would go a long way towards not confusing people.

*Edit: Just thought of something. If you're looking to do a hotkey for pressing T and S at the same time, I don't believe it can be done. I'm pretty sure you can only combine the modifier keys (Alt, Shift, Ctrl, Windows).

Just thought I'd mention that in case it was what you were really looking for.

Edited by Saunders

Share this post


Link to post
Share on other sites
tamir

*Edit: Just thought of something. If you're looking to do a hotkey for pressing T and S at the same time, I don't believe it can be done. I'm pretty sure you can only combine the modifier keys (Alt, Shift, Ctrl, Windows).

Just thought I'd mention that in case it was what you were really looking for.

<{POST_SNAPBACK}>

it was what i was looking for...

Share this post


Link to post
Share on other sites
tamir

it works, thanks!

now, is there a function that get the classname of window?

Share this post


Link to post
Share on other sites
themax90

PLEASE check the HELPFILE before you post man......

WinGetClassList

--------------------------------------------------------------------------------

Retrieves the classes from a window.

WinGetClassList ( "title" [, "text"] )

Parameters

title The title of the window to read.

text [optional] The text of the window to read.

Return Value

Success: Returns a string containing the window classes read.

Failure: Returns numeric 1 and sets @error to 1 if no window matches the criteria.

Remarks

Class names are linefeed (@LF) separated. WinGetClassList works on both minimized and hidden windows. Up to 64KB of text can be retrieved. If multiple windows match the criteria, the classes are read from the most recently active window.

Related

WinGetText, ControlCommand

Example

$text = WinGetClassList("Untitled -", "")

MsgBox(0, "Text read was:", $text)

WinGetHandle

--------------------------------------------------------------------------------

Retrieves the internal handle of a window.

WinGetHandle ( "title" [, "text"] )

Parameters

title The title of the window to read.

text [optional] The text of the window to read.

Return Value

Success: Returns a string containing the window handle value.

Failure: Returns "" (blank string) and sets @error to 1 if no window matches the criteria.

Remarks

This function is for use with the advanced WinTitleMatchMode options that allow you to use classnames and handles to specify windows rather than "title" and "text".

Once you have obtained the handle you can access the required window even if its title changes.

Related

WinTitleMatchMode (Option)

Example

; Identify the Notepad window that contains the text "this one" and get a handle to it

; Change into the WinTitleMatchMode that supports classnames and handles

AutoItSetOption("WinTitleMatchMode", 4)

; Get the handle of a notepad window that contains "this one"

$handle = WinGetHandle("classname=Notepad", "this one")

If @error Then

    MsgBox(4096, "Error", "Could not find the correct window")

Else

    ; Send some text directly to this window's edit control

    ControlSend($handle, "", "Edit1", "AbCdE")

EndIf

Most questions can be answered by searching in the helpfile for just classname of classnameid or whatever. Please do so first. No offense.....

AutoIt Smith

Share this post


Link to post
Share on other sites
tamir

i swear i always look in the help file before i post. i wrote in search "classname" and it didn't find this function, so don't get mad on me plz...

and thanks for the reply :idiot: .

Share this post


Link to post
Share on other sites
themax90

npjust look harder next time please.

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.