anixon Posted March 8, 2007 Share Posted March 8, 2007 I have written some code to run in background to monitor keys as and when they are pressed and would like to assign a process to Ctrl + Break. This is what the code looks like. CODE#include <Misc.au3> While 1 $dll = DllOpen("user32.dll") While 1 Sleep (50) If _IsPressed('11', $dll) and _IsPressed('91', $dll) Then MsgBox(0,"_IsPressed", "Ctrl + ScrLK ") Run(@ScriptDir & "\myp.exe") ExitLoop EndIf If _IsPressed('11', $dll) and _IsPressed('41', $dll) Then MsgBox(0,"_IsPressed", "Ctrl + A Key") Run(@ScriptDir & "\myp1.exe") ExitLoop EndIf If _IsPressed('11', $dll) and _IsPressed('42', $dll)Then MsgBox(0,"_IsPressed", " Ctrl + B Key ") Run(@ScriptDir & "\myp2.exe") ExitLoop EndIf WEnd DllClose($dll) WEnd Ctrl + Break does not work and I get the following message 'Process failed to respond; forcing abrupt termination...' Ctrl + A and Ctrl + B work without any problems. Can a process be assigned to the Ctrl + Break aka ScrlLk Key or can you error trap the 'Process failed error and assign that to a Run() function? Help is always appreciated Link to comment Share on other sites More sharing options...
PaulIA Posted March 9, 2007 Share Posted March 9, 2007 I have written some code to run in background to monitor keys as and when they are pressed and would like to assign a process to Ctrl + Break. This is what the code looks like. CODE#include <Misc.au3> While 1 $dll = DllOpen("user32.dll") While 1 Sleep (50) If _IsPressed('11', $dll) and _IsPressed('91', $dll) Then MsgBox(0,"_IsPressed", "Ctrl + ScrLK ") Run(@ScriptDir & "\myp.exe") ExitLoop EndIf If _IsPressed('11', $dll) and _IsPressed('41', $dll) Then MsgBox(0,"_IsPressed", "Ctrl + A Key") Run(@ScriptDir & "\myp1.exe") ExitLoop EndIf If _IsPressed('11', $dll) and _IsPressed('42', $dll)Then MsgBox(0,"_IsPressed", " Ctrl + B Key ") Run(@ScriptDir & "\myp2.exe") ExitLoop EndIf WEnd DllClose($dll) WEnd Ctrl + Break does not work and I get the following message 'Process failed to respond; forcing abrupt termination...' Ctrl + A and Ctrl + B work without any problems. Can a process be assigned to the Ctrl + Break aka ScrlLk Key or can you error trap the 'Process failed error and assign that to a Run() function? Help is always appreciatedThis catches Ctrl+Break: #include <Misc.au3> #include <GUIConstants.au3> do if _IsPressed(3) then ConsoleWrite("Ctrl-Break" & @CR) until GUIGetMsg() = $GUI_EVENT_CLOSE And then right after it does, AutoIt catches it and gives you the "Process failed to respond; forcing abrupt termination..." Auto3Lib: A library of over 1200 functions for AutoIt Link to comment Share on other sites More sharing options...
anixon Posted March 9, 2007 Author Share Posted March 9, 2007 This catches Ctrl+Break: #include <Misc.au3> #include <GUIConstants.au3> do if _IsPressed(3) then ConsoleWrite("Ctrl-Break" & @CR) until GUIGetMsg() = $GUI_EVENT_CLOSE And then right after it does, AutoIt catches it and gives you the "Process failed to respond; forcing abrupt termination..." Thanks for the response but I cannot seem to make it do what I want it to do. From a users perspective if they press Ctrl-Break then I want the routine to start an AutoIT executable I can see that your code writes Ctr-Break to the console a few times and that it has a do statement waiting for Ctrl Break to be input. The Ctrl = Break monitoring routine has live with a number of other key stroke combinations which are constantly monitored and when keyed [at any time] will perform other tasks. If you look at my code you will see that it monitors Ctrl+A and Ctrl+B so I also want it to constantly Monitor Ctrl+Break Perhaps you may be able to show me how to modify my routine with your process Cheers Ant... Link to comment Share on other sites More sharing options...
anixon Posted March 9, 2007 Author Share Posted March 9, 2007 (edited) Thanks for the response but I cannot seem to make it do what I want it to do. From a users perspective if they press Ctrl-Break then I want the routine to start an AutoIT executable I can see that your code writes Ctr-Break to the console a few times and that it has a do statement waiting for Ctrl Break to be input. The Ctrl = Break monitoring routine has live with a number of other key stroke combinations which are constantly monitored and when keyed [at any time] will perform other tasks. If you look at my code you will see that it monitors Ctrl+A and Ctrl+B so I also want it to constantly Monitor Ctrl+Break Perhaps you may be able to show me how to modify my routine with your process Cheers Ant... Sorry the above response is a result of not seeing the woods for the trees. I have figured it out I guess to put it simply the _ispressed attribute for Ctrl+Break is 3 which for some reason does not appear to be documented in Help. Thanks for your Help Ant... Edited March 9, 2007 by anixon Link to comment Share on other sites More sharing options...
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