CyberSlug Posted February 17, 2004 Author Share Posted February 17, 2004 Question... why does AutoIt not have a GetKeyState function? It looks like it wouldn't be anything more than a wrapper for the Windows API function of the same name...I thought about asking that--but then I saw this in sendkeys.cpp: // Now check the physical state (as best as the buggy API lets us) to see if any // of the modifier keys are held down. If they are - and none of the CTRLPER type // flags are used then force them to be released - even if our next keypress is // going to use the same modifier - it's just not close to reliable that way // This is not perfect, and if the user continues to twat around it will fail Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig! Link to comment Share on other sites More sharing options...
CyberSlug Posted February 17, 2004 Author Share Posted February 17, 2004 (edited) So program flow would be:Startup -> Register '(' -> '(' pressed -> Unregister '(' -> register ')' and 'ESC' -> Send 'SHIFTDOWN' -> ')' or 'ESC' pressed -> Send 'SHIFTUP' -> Register '('ShiftDown caused bad things to happen. (Well, the text I typed was all caps until I pressed the Shift key; and mouse clicks were messed up.)Also, I still got )0 with the closing parentheses. Edited February 17, 2004 by CyberSlug Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig! Link to comment Share on other sites More sharing options...
Valik Posted February 17, 2004 Share Posted February 17, 2004 ShiftDown caused bad things to happen. (Well, the text I typed was all caps until I pressed the Shift key; and mouse clicks were messed up.)What OS/editor? I have no problems at all when using {SHIFTDOWN} except the bug you found... Link to comment Share on other sites More sharing options...
CyberSlug Posted February 17, 2004 Author Share Posted February 17, 2004 What OS/editor? I have no problems at all when using {SHIFTDOWN} except the bug you found...Windows XP Pro sp1; TextPad 4.72It wasn't a major problem, but was more annoying than the other behavior. Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig! Link to comment Share on other sites More sharing options...
CyberSlug Posted February 17, 2004 Author Share Posted February 17, 2004 (edited) Maybe helpful Windows API info GetAsyncKeyState might be useful?EDIT: Comments in sendkeys.cpp://#define IsPhysicallyDown(vk) (GetKeyState(vk) & 0x8000) // Both GetKeyState and GetAsyncKeyState are unreliable :( //#define IsPhysicallyDown(vk) (GetAsyncKeyState(vk) & 0x80000000) // Both GetKeyState and GetAsyncKeyState are unreliable :( #define IsPhysicallyDown(vk) ( (GetAsyncKeyState(vk) & 0x80000000) || ((GetKeyState(vk) & 0x8000)) ) Edited February 17, 2004 by CyberSlug Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig! Link to comment Share on other sites More sharing options...
Valik Posted February 17, 2004 Share Posted February 17, 2004 Maybe helpful Windows API info GetAsyncKeyState might be useful?Couldn't get much from it or GetKeyState, but I did get GetKeyboardState working. I have something to work with at least, now. Link to comment Share on other sites More sharing options...
CyberSlug Posted February 17, 2004 Author Share Posted February 17, 2004 (edited) In case you missed my previous post edit:Sendkeys.cpp uses the macro IsKeyPhysicallyDown#define IsPhysicallyDown(vk) ( (GetAsyncKeyState(vk) & 0x80000000) || ((GetKeyState(vk) & 0x8000)) )Jon comments that each function is unreliable...Note: I'll let you look into the API. I'll work on improving the script using the functionality of the last AutoIt build you gave me Edited February 17, 2004 by CyberSlug Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig! Link to comment Share on other sites More sharing options...
Valik Posted February 17, 2004 Share Posted February 17, 2004 (edited) In case you missed my previous post edit:Sendkeys.cpp uses the macro IsKeyPhysicallyDown#define IsPhysicallyDown(vk) ( (GetAsyncKeyState(vk) & 0x80000000) || ((GetKeyState(vk) & 0x8000)) )Jon comments that each function is unreliable...Given that I could hold down the shift key forever and a day and neither of those functions would actually say that I was holding it down, I believe that... Edited February 17, 2004 by Valik Link to comment Share on other sites More sharing options...
CyberSlug Posted February 17, 2004 Author Share Posted February 17, 2004 (edited) By the way, I don't need to use Send("(") in my beginSense function at all. An alternative is:$bak = ClipGet() ClipPut("(") Send("^v");but this still clears the Shift-state, grr!!! ClipPut($bak) Would WinMenuSelectItem("","", "&Edit", "&Paste") work? No, the shift-state still gets cleared. Edited February 17, 2004 by CyberSlug Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig! Link to comment Share on other sites More sharing options...
Valik Posted February 17, 2004 Share Posted February 17, 2004 Send("{ALTDOWN}{NUMPAD0}{NUMPAD0}{NUMPAD4}{NUMPAD0}{ALTUP}") But as you said, Send clears the shift state. Link to comment Share on other sites More sharing options...
Valik Posted February 17, 2004 Share Posted February 17, 2004 (edited) And there was much stupidity between the two, for the answer was right in their face. Upon finding the answer, both feel very bad for all their foolish attempts. Enjoy: $control = ControlGetFocus("", "") HotKeySet("(", "test2") HotKeySet("!x", "quit") While 1 Sleep(250) WEnd Func test2() ; HotKeySet("(") ControlSend("", "", $control, "(") TrayTip("Hmm", "Hmm", 5, 16) ; HotKeySet("(", "test2") EndFunc Func quit() Exit EndFunc Edited February 17, 2004 by Valik Link to comment Share on other sites More sharing options...
CyberSlug Posted February 17, 2004 Author Share Posted February 17, 2004 Send("{ALTDOWN}{NUMPAD0}{NUMPAD0}{NUMPAD4}{NUMPAD0}{ALTUP}")But as you said, Send clears the shift state.Send("{ASC 40}") ;a bit simpler Thanks for trying, though! I'm out of ideas... Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig! Link to comment Share on other sites More sharing options...
Valik Posted February 17, 2004 Share Posted February 17, 2004 Send("{ASC 40}") ;a bit simpler Thanks for trying, though! I'm out of ideas...In case you missed it, look above the post I am quoting. Link to comment Share on other sites More sharing options...
CyberSlug Posted February 17, 2004 Author Share Posted February 17, 2004 For Valik: For Me: :iamstupid: Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig! Link to comment Share on other sites More sharing options...
CyberSlug Posted February 17, 2004 Author Share Posted February 17, 2004 Okay, now I just need to see how well ControlSend works with various text editors. Title = "EditPadPro" Class = "TEditPadProEditor1" Title = "TextPad" Class = "HSEditor1" Title = "Crimson Editor" Class = "AfxFrameOrView421" Title = "Code-Genie" Class = "AfxFrameOrView42s1" Title = "AnyEdit" Class = "Scintilla1" Title = "UltraEdit-32" Class = "EditControl1" Title = "EditPlus" Class = "AfxFrameOrView42s1" Title = "MED" Class = "MRED_TEXTWIN_CLASS1" Title = "NoteTab" Class = "TClipDoc?"???????? Title = "Source Edit" Class = "ThunderRT6MDIForm"???? Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig! Link to comment Share on other sites More sharing options...
Valik Posted February 17, 2004 Share Posted February 17, 2004 (edited) For Valik: For Me: :iamstupid: :iamstupid: :iamstupid: :iamstupid: :iamstupid: How many days did it take to come up with that? I knew the answer would be simple... just... not THAT simple. I am DEFINITELY using a full-hotkey thing now, though, since I shouldn't have to worry about shift states.And for ANYBODY who dares say ANYTHING at all about this might not work with some editors, all I have to say to you is :postal: (Even you CyberSlug, I saw the post you made while I typed this ) Edited February 17, 2004 by Valik Link to comment Share on other sites More sharing options...
CyberSlug Posted February 17, 2004 Author Share Posted February 17, 2004 (edited) Microsoft Windows XP [Version 5.1.2600] (C) Copyright 1985-2001 Microsoft Corp. C:\>edit *procedes to try the DOS Edit program* I'm afraid ControlSend doesn't work, Valik :lmao: P.S. I think I'll call it a night. Edited February 17, 2004 by CyberSlug Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig! Link to comment Share on other sites More sharing options...
Somerset Posted February 17, 2004 Share Posted February 17, 2004 uh uh uh uhhhhhhhhhhhhhhhhhhhhhhhh shoot i am to scared to remark... Link to comment Share on other sites More sharing options...
CyberSlug Posted February 17, 2004 Author Share Posted February 17, 2004 (edited) Take a look at this comment in my LoadDatabase function ; the extra space is important so that, for example, ; "Send" does not match "ControlSend" in my lookup function BTW: I'll need to fix up Send($SELECT & $COPY & $REPOSITION) and do some other swiching around, so I might not have an updated version posted until tomorrow. I *hope* I can get $SELECT & $COPY & $REPOSITION to work right, because one of them relies upon the Shift key...... I'm having problems with this..... It appears the Ctrl+Shift+Left select word oparation causes stack corruption or something.... It works fine the first time but not subsequent times. Maybe full key-trapping is necessary after all...... Edited February 17, 2004 by CyberSlug Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig! Link to comment Share on other sites More sharing options...
Valik Posted February 17, 2004 Share Posted February 17, 2004 (edited) CyberSlug, here's something that should work. Keep in mind, you'll still need to continue to get the select-left, copy and clear selection key commands from an INI file. This test script works nicely in TextPad. Notepad uses a different method for jumping back to the end of the selected text (But Notepad is retarded about it). I would assume most other editors would use something similar to TextPad, though.Opt("SendKeyDelay", 1) HotKeySet("!x", "Quit") HotKeySet("(", "Test") While 1 Sleep(250) WEnd Func Test() ControlSend("", "", ControlGetFocus("", ""), "^+{LEFT}^c{RIGHT}(") $res = ClipGet() TrayTip("Clipboard", $res, 5, 16) EndFunc Func Quit() Exit EndFuncEdit: The above works well as it is... but, whenever I try to plug that into your AutoSense script, it causes issues. I have a choice of either having it trim all but the first letter of the word, or busting the stack. I have ideas on how to fix it though which might help me figure out why we keep breaking the stack so I can maybe give Jon enough information to see if it can be fixed. Edited February 17, 2004 by Valik 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