Morel Posted October 31, 2006 Posted October 31, 2006 I Have Autoit Application And i Define a HotKey Thet When I Press The {Enter} Button Its Do a ControlClick So far so good. But When i am Work With Any Other Application When i Press The {Enter} Key its Lunch Again The Autoit Script How Can i Solve That only when the Autoit Application is in focus The HotKey Will Work Othwise It Act Normaly 10X Morel
theguy0000 Posted October 31, 2006 Posted October 31, 2006 WinActive () The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN
Morel Posted October 31, 2006 Author Posted October 31, 2006 I Didnt Understand You Can You Give me an Exapmle Please Thanks Morel
Morel Posted October 31, 2006 Author Posted October 31, 2006 I Have Try To Use WinActive() Function Using This Code HotKeySet("{Enter}","HotKeyTest") Func HotKeyTest() If WinActive ("AForm1","") Then ControlClick("","",$Button1) EndIf EndFunc But When The Application is not in Focus I Cant Use The Enter Key any Idea Somone ? Morel
Krikov Posted October 31, 2006 Posted October 31, 2006 Hello Morel Try This Nice Exmaple #include <GuiConstants.au3> HotKeySet("{ENTER}", "catchguikey") $gui = GuiCreate("Hotkey Test") GuiCtrlCreateLabel("Press Enter", 0, 0) GuiSetState() While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop Wend Func catchguikey() Local $opt = Opt("WinTitleMatchMode", 4) If WinGetHandle("active") = $gui Then If @HotKeyPressed = "{ENTER}" Then ;Do something here ToolTip("Key Pressed") Sleep(1000) ToolTip("") EndIf Else HotKeySet(@HotKeyPressed) Send(@HotKeyPressed) HotKeySet(@HotKeyPressed, "catchguikey") EndIf Opt("WinTitleMatchMode", $opt) EndFunc Krikov [topic="63488"][font="Arial"]Krikov Tray Quick Menu[/font][/topic]
Helge Posted October 31, 2006 Posted October 31, 2006 (edited) Quick and untested, but should work.$regged = 0 $title = "AForm1" $Button1 = "Button1" While 1 ; register if window is active and hotkey isn't registered If $regged = 0 AND WinActive($title) Then $regged = 1 HotKeySet("{Enter}", "HotKeyTest") EndIf ; unregister if window isn't active and hotkey is registered If $regged = 1 AND NOT WinActive($title) Then $regged = 0 HotKeySet("{Enter}") EndIf Sleep(10) WEnd Func HotKeyTest() ControlClick("","",$Button1) EndFunc Edited October 31, 2006 by Helge
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