Hawkwing Posted March 25, 2009 Share Posted March 25, 2009 (edited) I'm trying to create a script to make shortcuts. For example, I could create a shortcut for "ila" so that when I press those keys in that order it deletes that and sends "i love autoit". I don't know a whole lot about how to do this, all I've got is the main gui. I'm planning on making it so that you can hit the new button and have it create a child gui for the shortcut and the text that it will write. Same for the edit button, except that it will have a delete button to delete the shortcut. I was planning on using an ini to store the shortcuts. I can do most of the stuff myself, but I have no idea how to create the listview items. Opt ("guioneventmode", 1) $gui = GUICreate ("Hotkeys", 220, 386) GUISetOnEvent ($GUI_EVENT_CLOSE, "guievent", $gui) $listview = GUICtrlCreateListView ("Hotkey|Text Written ", 5, 5, 210, 320) $buttonnew = GUICtrlCreateButton ("New Hotkey", 5, 330, 210, 23) $buttonedit = GUICtrlCreateButton ("Edit Hotkey", 5, 358, 210, 23) GUISetState (@SW_SHOW, $gui) Func guievent() Switch @GUI_CtrlId Case $GUI_EVENT_CLOSE Exit Case $GUI_EVENT_MINIMIZE WinSetState ("Hotkeys", "", @SW_MINIMIZE) EndSwitch EndFunc Edited March 25, 2009 by pigeek The Wheel of Time turns, and Ages come and pass, leaving memories that become legend. Legend fades to myth, and even myth is long forgotten when the Age that gave it birth comes again. Link to comment Share on other sites More sharing options...
picea892 Posted March 27, 2009 Share Posted March 27, 2009 Hi Take some time and mess around with _ispressed and hotkeyset. Once you get that running, then start working on adding in your GUI. Below are two script fragments to get you started. Type ILA and it will give you a messagebox stating I Love Autoit. What you will next need to add is something to reset $i, $l and $a if any other key is pressed. CODEHotKeySet("i","ifunc") hotkeyset("l","lfunc") hotkeyset("a","afunc") hotkeyset("{esc}","enditall") global $i=0, $l=0, $a=0 $dll = DllOpen("user32.dll") While 1 sleep(100) WEnd Func ifunc() $i=1 EndFunc Func lfunc() if $i=1 then $l=1 EndFunc Func afunc() if $i=1 and $l=1 then MsgBox(0,"","I LOVE AUTOIT") $i=0 $l=0 $a=0 EndFunc Func enditall() Exit EndFunc CODE#Include <Misc.au3> global $i=0, $l=0, $a=0 $dll = DllOpen("user32.dll") While 1 if _IsPressed("1B", $dll) then exit if _IsPressed("49", $dll) then $i=1 if _IsPressed("4C", $dll) and $i=1 then $l=1 if _IsPressed("41", $dll) and $i=1 and $l=1 then MsgBox(0,"","I LOVE AUTOIT") EndIf sleep(100) WEnd Link to comment Share on other sites More sharing options...
Hawkwing Posted March 30, 2009 Author Share Posted March 30, 2009 Hotkeyset won't work. If you set a as a hotkey and then press it while the script is running, it starts the function, but it doesn't send a to whatever your typing. I think I can get _IsPressed to work, but don't know how to convert the variables to the ispressed thing (i=1B, l=49, and so forth). The Wheel of Time turns, and Ages come and pass, leaving memories that become legend. Legend fades to myth, and even myth is long forgotten when the Age that gave it birth comes again. Link to comment Share on other sites More sharing options...
Tvern Posted March 30, 2009 Share Posted March 30, 2009 (edited) Hotkeyset won't work. If you set a as a hotkey and then press it while the script is running, it starts the function, but it doesn't send a to whatever your typing.I think I can get _IsPressed to work, but don't know how to convert the variables to the ispressed thing (i=1B, l=49, and so forth).When you set a hotkey, AutoIt captures the key-press and does not pass it on to the active application, with one exception: the Lock keys (NumLock, CapsLock, and ScrollLock) still toggle their respective state!To Send() a key combination which will trigger a HotKeySet() event, either use ControlSend() or unregister the HotKeySet() event, otherwise, the Send() event may trigger an infinite loop.; capture and pass along a keypressHotKeySet("{Esc}", "captureEsc")Func captureEsc() ; ... can do stuff here HotKeySet("{Esc}") Send("{Esc}") HotKeySet("{Esc}", "captureEsc")EndFuncI can think of 3 ways to try this, all with their shortcomings. You could register WM_KEYDOWN, which requires your gui to have focus, use _Ispressed, which requires you to figure out if the same key is pressed multiple times, or if the key is just held down a while, or hotkeyset, which requires you to hotkey every character you want to use and pass it on afterwards.Personally I'd go for hotkeying.You might have a hard time getting help on the subject btw, as autoit dev's try to avoid getting associated with keyloggers.Edit: Have a look at the example I PM'd you. Edited March 30, 2009 by Tvern 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