Jump to content

Recommended Posts

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
:whistle:
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 post
Share on other sites
  • Replies 72
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

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 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 post
Share on other sites

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)) )
:whistle: Edited 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 post
Share on other sites

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 :whistle:

Edited 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 post
Share on other sites

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 by Valik
Link to post
Share on other sites

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)

:whistle: Would WinMenuSelectItem("","", "&Edit", "&Paste") work? B)

:angry: No, the shift-state still gets cleared.

Edited 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 post
Share on other sites

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 by Valik
Link to post
Share on other sites

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 post
Share on other sites

For Valik:  :whistle:  B)  :angry:

For Me: :iamstupid:  :lmao:

:P :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 :evil: )

Edited by Valik
Link to post
Share on other sites

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 :whistle::lmao:B)

P.S. I think I'll call it a night.

Edited 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 post
Share on other sites

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

:evil:B):lmao:

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.

:whistle: I *hope* I can get $SELECT & $COPY & $REPOSITION to work right, because one of them relies upon the Shift key...... :angry: I'm having problems with this..... It appears the Ctrl+Shift+Left select word oparation causes stack corruption or something.... :P It works fine the first time but not subsequent times. Maybe full key-trapping is necessary after all......

Edited 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 post
Share on other sites

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
EndFunc

Edit: 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 by Valik
Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...