Jump to content

Control Send


Recommended Posts

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

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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