ForsakenGod Posted February 4, 2010 Posted February 4, 2010 Hello , I ve got some problems i am trying control send This is the code i have so far is there any mistake ? 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
GodlessSinner Posted February 4, 2010 Posted February 4, 2010 (edited) ControlSend($handle ,"" ,"" ,"+") not right, you forgot about controlID. Use Autoit_Window_Info to get ctrl id ControlSend ( "title", "text", controlID, "string") Edited February 4, 2010 by Godless _____________________________________________________________________________
ForsakenGod Posted February 4, 2010 Author Posted February 4, 2010 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 ?
Mat Posted February 4, 2010 Posted February 4, 2010 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 AutoIt Project Listing
PsaltyDS Posted February 4, 2010 Posted February 4, 2010 (edited) 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". Edit: Oops, too slow. Edited February 4, 2010 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
Mat Posted February 4, 2010 Posted February 4, 2010 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". 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. AutoIt Project Listing
ForsakenGod Posted February 4, 2010 Author Posted February 4, 2010 (edited) Thanks for support . Actualy i got only 1 problem It now uses the handle and focuss on the window of interest BUT it does not send the needet key it does not want to send the + key idk why Edited February 4, 2010 by ForsakenGod
Mat Posted February 4, 2010 Posted February 4, 2010 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) AutoIt Project Listing
ForsakenGod Posted February 4, 2010 Author Posted February 4, 2010 (edited) 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 ControlSend($handle ,"" ,"" ,"{+}") Nice & working Thanks for your support Edited February 4, 2010 by ForsakenGod
PsaltyDS Posted February 4, 2010 Posted February 4, 2010 @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
Mat Posted February 4, 2010 Posted February 4, 2010 @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! AutoIt Project Listing
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now