Jump to content
Sign in to follow this  
ForsakenGod

Control Send

Recommended Posts

ForsakenGod

Hello ,

I ve got some problems i am trying control send :D This is the code i have so far is there any mistake ? :huggles: Or can s1 please explain me this ? :

$handle = WinGetHandle("Window of interest")
HotKeySet("{F5}" ,"Start")

MsgBox(1,"","The win handle is " & $handle)

Func Start()
    WinActivate($handle)
    WinWaitActive($handle)
    ControlSend($handle ,"" ,"" ,"+")
EndFunc

Thanks in advance

Share this post


Link to post
Share on other sites
GodlessSinner

ControlSend($handle ,"" ,"" ,"+")

not right, you forgot about controlID. Use Autoit_Window_Info to get ctrl id

ControlSend ( "title", "text", controlID, "string")

Edited by Godless

_____________________________________________________________________________

Share this post


Link to post
Share on other sites
ForsakenGod

ControlSend($handle ,"" ,"" ,"+")
- not right

ControlSend ( "title", "text", controlID, "string" [, flag] )

Hmm so actually if i would like to send an key + to window of $handle how would it be ?

Share this post


Link to post
Share on other sites
Mat

Hmm so actually if i would like to send an key + to window of $handle how would it be ?

No, that should work... Your problem is that the script exits as soon as the message box closes, so you need a loop there as well.

Global $handle = WinGetHandle("Window of interest") ; Must be declared in global scope to be used in functions.
HotKeySet("{F5}" ,"Start")
HotkeySet("{ESC}", "End")

MsgBox(1,"","The win handle is " & $handle)

While 1 ; Loop here forever (until "esc" hotkey pressed)
    Sleep(100)
WEnd

Func Start()
    WinActivate($handle)
    WinWaitActive($handle)
    ControlSend($handle ,"" ,"" ,"+")
EndFunc

Func End()
    Exit
EndFunc

Share this post


Link to post
Share on other sites
PsaltyDS

The control ID is not required, so you can send it just with the window handle and the string to send. I don't, however, see any loop to keep the script alive while waiting for "F5".

:D

Edit: Oops, too slow.

Edited by PsaltyDS

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites
Mat

The control ID is not required, so you can send it just with the window handle and the string to send. I don't, however, see any loop to keep the script alive while waiting for "F5".

:D

Edit: Oops, too slow.

Just as a test I tried this... It would seem it queues it nicely for you! It's something I never really thought about, but pressing it 5 times while the first MsgBox is showing triggers the function 5 times.

HotKeySet("{F5}", "_Go")

MsgBox(0, "Press Hotkey now!!", "Press the hotkey pls!")

Func _Go()
    MsgBox(0, "Hotkey Recieved", "This test actually worked")
EndFunc

This could have a few negative effects... But I think its pretty cool.

Share this post


Link to post
Share on other sites
ForsakenGod

Thanks for support . Actualy i got only 1 problem :D It now uses the handle and focuss on the window of interest BUT it does not send the needet key :huggles: it does not want to send the + key idk why :

Edited by ForsakenGod

Share this post


Link to post
Share on other sites
ForsakenGod

It would appear that "+" is not sent : Unless you use the raw mode option:

ControlSend($handle ,"" ,"" ,"+", 1)

This worked for me:

ControlSend("[CLASS:SciTEWindow]", "", "", "+", 1)

Hehe i was playing with it a bit and here is what i have :D

ControlSend($handle ,"" ,"" ,"{+}")

Nice & working

Thanks for your support :huggles:

Edited by ForsakenGod

Share this post


Link to post
Share on other sites
PsaltyDS

@Mat: Good catch! I've had that issue before and should have seen it too! Without the raw flag, "+" is just "{SHIFT}", as in Send() code.

:-)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites
Mat

@Mat: Good catch! I've had that issue before and should have seen it too! Without the raw flag, "+" is just "{SHIFT}", as in Send() code.

:-)

As ForsakenGod pointed out, you just need to escape it ("{+}"), I forgot all about shift!

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  

×