Page 2 of 2 FirstFirst 12
Results 41 to 59 of 59

Thread: Global Hook

  1. #41

    Thread Starter
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,429

    Re: Global Hook

    Ahhh, I won't use SetForegroundWindow either for the same reason
    (instead, I'll use SetActiveWindow)

  2. #42

    Thread Starter
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,429

    Re: Global Hook

    Update:
    1. Using SetForegroundWindow to enable the use of SendKeys, always makes my app the return hWnd.

    2. If I use SetActiveWindow to overcome this, I can no longer use SendKeys!

    3. The delima is If I now use PostMessage to emulate SendKeys (%{Tab}) I would require the hWmd of the now non-focused window..........


    Still trying

  3. #43
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: Global Hook

    Another idea... Use GetNextWindow (or call GetWindow which does the same thing) with GW_HWNDNEXT to get the next window in the ZOrder.

  4. #44

    Thread Starter
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,429

    Re: Global Hook

    Will give it a shot.

    I must say I was surprised when I couldn't find any posts similar to this (I think the question was answered but no solution). I would be keen to get this up nad running as
    others may benifit too.


    Thanks for your inputs on this Joacim, I appreciate it .



    Cheers,

  5. #45

    Thread Starter
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,429

    Re: Global Hook

    Was successful, but flakey

    I tried many combinations, even to the point of not having to use SendKeys (as the Next Windows hWnd was made available).

  6. #46
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: Global Hook

    Sorry, I stopped reading after the word "successful"

  7. #47

    Thread Starter
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,429

    Re: Global Hook

    Quote Originally Posted by Joacim Andersson
    Sorry, I stopped reading after the word "successful"

  8. #48

    Thread Starter
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,429

    Re: Global Hook

    Through sheer determination I revisited the above APIs' - SUCCESS!

    In short, and NO Sub-Classing, I used:

    SetForeGroundWindow(myApps hWnd)
    GetNextWindow(myApps hWnd, GW_HWNDNEXT)
    SetForeGroundWindow(retval of GetNextWindow)


    Viola....

    Clicking the SysTray Icon takes the focus, SetForegroundWindow ensures myApp is ready for GetNext,
    then capture the Next hWnd,
    Now set the focus back to the losing apps Window......

    I will post the entire app in the .Net Forum once done.


    I want to keep this un-resolved, as I would like feedback on a Global (Sub-Classed) method
    using the WM_ACTIVEAPP as M$ states it should work
    .



    At this stage many, many thanks to Joacim for his persistance





    Regards,

  9. #49

    Thread Starter
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,429

    Re: Global Hook

    Initial testing seems OK with Access, Excel.

    Joacim, at this stage I cannot 'rate' you as I need to share it around. In the interim, please take ten points outa the bit bucket



    Bruce.

  10. #50

    Thread Starter
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,429

    Re: Global Hook

    Beta .Net code now posted here (post #19):
    http://www.vbforums.com/showthread.php?t=366585

  11. #51
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    Re: Global Hook

    OK,

    I've been playing with this code under VB6 for a while. The method as spelled out in the .Net forum doesn't work in VB6 since the "Next Window" is not the one we are looking for. I find that I have to first iterate through all the "tooltips_class32" windows first.

    In addition, once we find the top level window we can't just send a WM_COPY message to that window since we really want the Textbox child of that window. I've been testing on Notepad and EditPadPro. Here is what I've found works so far.
    VB Code:
    1. [FONT=Courier New][COLOR=#0000FF]Private[/COLOR] [COLOR=#0000FF]Sub[/COLOR] DoIt()
    2.     [COLOR=#0000FF]Dim[/COLOR] lhWnd [COLOR=#0000FF]As[/COLOR] [COLOR=#0000FF]Long
    3. [/COLOR]    [COLOR=#0000FF]Dim[/COLOR] lThreadID [COLOR=#0000FF]As[/COLOR] [COLOR=#0000FF]Long
    4. [/COLOR]    [COLOR=#0000FF]Dim[/COLOR] lProcessID [COLOR=#0000FF]As[/COLOR] [COLOR=#0000FF]Long
    5. [/COLOR]    [COLOR=#0000FF]Dim[/COLOR] RetInfo [COLOR=#0000FF]As[/COLOR] GUITHREADINFO
    6.     [COLOR=#0000FF]Dim[/COLOR] lpClassName [COLOR=#0000FF]As[/COLOR] [COLOR=#0000FF]String
    7. [/COLOR]    lhWnd = GetForegroundWindow
    8.    
    9.     [COLOR=#007A00]'the next few windows are tooltips_class32 class windows
    10. [/COLOR]    [COLOR=#007A00]'associated with the taskbar
    11. [/COLOR]    [COLOR=#0000FF]While[/COLOR] GetNextClassName(lhWnd) = "[COLOR=#7A0000]tooltips_class32[/COLOR]"
    12.         DoEvents
    13.     [COLOR=#0000FF]Wend
    14. [/COLOR]    
    15.     [COLOR=#007A00]'Whoops don't do this again
    16. [/COLOR]    'Text1 = Text1 & GetNextClassName(lhWnd) & vbTab & Hex(lhWnd) & vbCrLf
    17.  
    18.     [COLOR=#007A00]'get threadID of thatwindow
    19. [/COLOR]    lThreadID = GetWindowThreadProcessId(lhWnd, lProcessID)
    20.     [COLOR=#007A00]'and set focus back to that window
    21. [/COLOR]    SetForegroundWindow lhWnd
    22.     [COLOR=#007A00]'now get thread info
    23. [/COLOR]    RetInfo.cbSize = LenB(RetInfo)
    24.     [COLOR=#0000FF]Call[/COLOR] GetGUIThreadInfo(lThreadID, RetInfo)
    25.     [COLOR=#007A00]'hwndCaret is the child window we want
    26. [/COLOR]    Text1 = Text1 & Hex(RetInfo.hwndCaret) & vbTab & Hex(RetInfo.hwndActive) & vbCrLf
    27.    
    28.     Clipboard.Clear
    29.     [COLOR=#0000FF]Call[/COLOR] PostMessage(RetInfo.hwndCaret, WM_COPY, 0&, 0&)
    30.     DoEvents
    31.         [COLOR=#007A00]'Check for valid Pasted data
    32. [/COLOR]        [COLOR=#0000FF]If[/COLOR] [COLOR=#0000FF]Not[/COLOR] Clipboard.GetFormat(vbCFText) [COLOR=#0000FF]Then
    33. [/COLOR]            MsgBox "[COLOR=#7A0000]Please select some text first.[/COLOR]", vbOKOnly
    34.         [COLOR=#0000FF]Else
    35. [/COLOR]            Text1 = Text1 & Clipboard.GetText & vbCrLf
    36.             [COLOR=#007A00]'CheckSpelling Clipboard.GetText
    37. [/COLOR]        [COLOR=#0000FF]End[/COLOR] [COLOR=#0000FF]If
    38. [/COLOR]
    39. [COLOR=#0000FF]End[/COLOR] [COLOR=#0000FF]Sub
    40. [/COLOR]
    41. [COLOR=#0000FF]Private[/COLOR] [COLOR=#0000FF]Function[/COLOR] GetNextClassName(lhWnd [COLOR=#0000FF]As[/COLOR] [COLOR=#0000FF]Long[/COLOR]) [COLOR=#0000FF]As[/COLOR] [COLOR=#0000FF]String
    42. [/COLOR]    [COLOR=#0000FF]Dim[/COLOR] lpClassName [COLOR=#0000FF]As[/COLOR] [COLOR=#0000FF]String
    43. [/COLOR]    lhWnd = GetWindow(lhWnd, GW_HWNDNEXT)
    44.     lpClassName = Space(255)
    45.     GetClassName lhWnd, lpClassName, 255
    46.     GetNextClassName = Left(lpClassName, InStr(lpClassName, Chr(0)) - 1)
    47. [COLOR=#0000FF]End[/COLOR] [COLOR=#0000FF]Function[/COLOR][/FONT]
    Like you, I didn't get the WM_APPACTIVATE code to work, but I think I can so I'll keep working on it.

    Also I never liked the Word dialog box so I'll adapt my spellchecker to this code. It is in my "RichtextBox Tricks and Tips" thread. That code brings up a context menu with spelling suggestions rather than that ugly Word Box.
    Last edited by moeur; Oct 21st, 2005 at 06:47 PM.

  12. #52
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    Re: Global Hook

    Another thought I had was instead of using a task tray icon to activate we could install a global keyboard hook and look for a hot-key. This way we would already have the handle to the edit window.

  13. #53
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: Global Hook

    @moeur, even though I really like the way you where thinking in the above solotion there is a huge problem in that logic... The problem itself is well known, using GetWindow in a loop can freeze your app if a user happens to close a window while the loop is running... Even the MSDN Library tells you to not use this approach (and I'm quoting)
    An application that calls GetWindow to perform this task [read EnumWindows] (in a loop) risks being caught in an infinite loop or referencing a handle to a window that has been destroyed.

  14. #54
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    Re: Global Hook

    It's simple enough to put a counter in the loop that exits the loop on too many iterations. In either case you have to work through the windows to get to the one you want.

  15. #55
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: Global Hook

    All I'm saying ís that you should use EnumWindows instead. You can apply your logic in the callback procedure just as well... Please remember: I liked your logic

  16. #56
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    Re: Global Hook

    But I don't see how EnumWindows will give us the "Next Window" in Z-order.

  17. #57
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    Re: Global Hook

    Some more comments on this:
    WM_APPACTIVATE is not going to work for the task tray icon method because what you'd have to subclass would be the tray.

    The method I posted above is still kind of flaky since sometimes there are other windows besides tooltips_class32 windows between your window and the previous window. For instance I've seen a window with a class name "WorkerW".

    This method also does not work for things like the VBForums edit box.

  18. #58
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    Re: Global Hook

    I have come up with a robust solution to this problem.
    Whenever a top-level window is activated, a global message is sent that can be trapped with a global WH_SHELL hook. If we keep track of which program was activated last, then when our icon is clicked, we have all the info we need.

    Instead of having to set a global WH_SHELL hook (which would require C++) we can instead use an API function that Penagate mentioned in another thread called RegisterShellHookWindow. This function directs all shell messages to our window procedure so we just have to subclass our own window.

    To set up this functionality, you do something like this
    VB Code:
    1. [FONT=Courier New][COLOR=#0000FF]Option Explicit
    2. [/COLOR]
    3. [COLOR=#0000FF]Private[/COLOR] [COLOR=#0000FF]Declare[/COLOR] [COLOR=#0000FF]Function[/COLOR] RegisterShellHookWindow [COLOR=#0000FF]Lib[/COLOR] "[COLOR=#7A0000]user32[/COLOR]" ( _
    4.     [COLOR=#0000FF]ByVal[/COLOR] hwnd [COLOR=#0000FF]As[/COLOR] [COLOR=#0000FF]Long[/COLOR] _
    5. ) [COLOR=#0000FF]As[/COLOR] [COLOR=#0000FF]Long
    6. [/COLOR]
    7. [COLOR=#0000FF]Private[/COLOR] [COLOR=#0000FF]Declare[/COLOR] [COLOR=#0000FF]Function[/COLOR] RegisterWindowMessage [COLOR=#0000FF]Lib[/COLOR] "[COLOR=#7A0000]user32[/COLOR]" [COLOR=#0000FF]Alias[/COLOR] "[COLOR=#7A0000]RegisterWindowMessageW[/COLOR]" ( _
    8.     [COLOR=#0000FF]ByVal[/COLOR] lpString [COLOR=#0000FF]As[/COLOR] [COLOR=#0000FF]Long[/COLOR] _
    9. ) [COLOR=#0000FF]As[/COLOR] [COLOR=#0000FF]Long
    10. [/COLOR]
    11. [COLOR=#0000FF]Private[/COLOR] WM_SHELLHOOKMESSAGE [COLOR=#0000FF]As[/COLOR] [COLOR=#0000FF]Long
    12. Private[/COLOR] [COLOR=#0000FF]Const[/COLOR] HSHELL_WINDOWCREATED = 1
    13. [COLOR=#0000FF]Private[/COLOR] [COLOR=#0000FF]Const[/COLOR] HSHELL_WINDOWDESTROYED = 2
    14. [COLOR=#0000FF]Private[/COLOR] [COLOR=#0000FF]Const[/COLOR] HSHELL_ACTIVATESHELLWINDOW = 3
    15. [COLOR=#0000FF]Private[/COLOR] [COLOR=#0000FF]Const[/COLOR] HSHELL_WINDOWACTIVATED = 4
    16. [COLOR=#0000FF]Private[/COLOR] [COLOR=#0000FF]Const[/COLOR] HSHELL_GETMINRECT = 5
    17. [COLOR=#0000FF]Private[/COLOR] [COLOR=#0000FF]Const[/COLOR] HSHELL_REDRAW = 6
    18. [COLOR=#0000FF]Private[/COLOR] [COLOR=#0000FF]Const[/COLOR] HSHELL_TASKMAN = 7
    19. [COLOR=#0000FF]Private[/COLOR] [COLOR=#0000FF]Const[/COLOR] HSHELL_LANGUAGE = 8
    20. [COLOR=#0000FF]Private[/COLOR] [COLOR=#0000FF]Const[/COLOR] HSHELL_SYSMENU = 9
    21. [COLOR=#0000FF]Private[/COLOR] [COLOR=#0000FF]Const[/COLOR] HSHELL_ENDTASK = 10
    22. [COLOR=#0000FF]Private[/COLOR] [COLOR=#0000FF]Const[/COLOR] HSHELL_ACCESSIBILITYSTATE = 11
    23. [COLOR=#0000FF]Private[/COLOR] [COLOR=#0000FF]Const[/COLOR] HSHELL_APPCOMMAND = 12
    24. [COLOR=#0000FF]Private[/COLOR] [COLOR=#0000FF]Const[/COLOR] HSHELL_WINDOWREPLACED = 13
    25. [COLOR=#0000FF]Private[/COLOR] [COLOR=#0000FF]Const[/COLOR] HSHELL_WINDOWREPLACING = 14
    26. [COLOR=#0000FF]Private[/COLOR] [COLOR=#0000FF]Const[/COLOR] HSHELL_HIGHBIT = &H8000
    27. [COLOR=#0000FF]Private[/COLOR] [COLOR=#0000FF]Const[/COLOR] HSHELL_FLASH = HSHELL_REDRAW [COLOR=#0000FF]Or[/COLOR] HSHELL_HIGHBIT
    28. [COLOR=#0000FF]Private[/COLOR] [COLOR=#0000FF]Const[/COLOR] HSHELL_RUDEAPPACTIVATED = HSHELL_WINDOWACTIVATED [COLOR=#0000FF]Or[/COLOR] HSHELL_HIGHBIT
    29.  
    30. [COLOR=#0000FF]Private[/COLOR] [COLOR=#0000FF]Sub[/COLOR] Form_Load()
    31.     [COLOR=#0000FF]Set[/COLOR] FormSubClass = [COLOR=#0000FF]New[/COLOR] clsSubClass
    32.  
    33.     [COLOR=#007A00]'get dynamic shell message number
    34. [/COLOR]    WM_SHELLHOOKMESSAGE = RegisterWindowMessage(StrPtr("[COLOR=#7A0000]SHELLHOOK[/COLOR]"))
    35.  
    36.     [COLOR=#007A00]'we want to receive shell messages
    37. [/COLOR]    RegisterShellHookWindow Me.hwnd
    38.     FormSubClass.Enable Me.hwnd
    39.  
    40.     [COLOR=#007A00]'add icon to task tray
    41. [/COLOR]    [COLOR=#0000FF]With[/COLOR] NotifyIcon
    42.         .Icon = Me.Icon
    43.         .Tip = "[COLOR=#7A0000]Spell Checker[/COLOR]"
    44.         .Add
    45.     [COLOR=#0000FF]End[/COLOR] [COLOR=#0000FF]With
    46. [/COLOR]
    47.     Text1 = ""
    48.     Me.Hide
    49. [COLOR=#0000FF]End[/COLOR] [COLOR=#0000FF]Sub[/COLOR][/FONT]
    In this code, I use my subclasser class (clsSubClass) and taskicon OCX control (NotifyIcon) but you can do it any way you would like. Once this is done we will receive the shell messages in our window procedure.

    What we want to do is keep track of the last window that was activated, so in the window procedure
    VB Code:
    1. [FONT=Courier New][COLOR=#0000FF]Private[/COLOR] [COLOR=#0000FF]Sub[/COLOR] FormSubClass_WMArrival(hwnd [COLOR=#0000FF]As[/COLOR] [COLOR=#0000FF]Long[/COLOR], uMsg [COLOR=#0000FF]As[/COLOR] [COLOR=#0000FF]Long[/COLOR], wParam [COLOR=#0000FF]As[/COLOR] [COLOR=#0000FF]Long[/COLOR], lParam [COLOR=#0000FF]As[/COLOR] [COLOR=#0000FF]Long[/COLOR], lRetVal [COLOR=#0000FF]As[/COLOR] [COLOR=#0000FF]Long[/COLOR])
    2.     [COLOR=#007A00]'don't do anything if spell checking is in progress
    3. [/COLOR]    [COLOR=#0000FF]If[/COLOR] PauseMessages [COLOR=#0000FF]Then[/COLOR] [COLOR=#0000FF]Exit[/COLOR] [COLOR=#0000FF]Sub
    4. [/COLOR]    [COLOR=#0000FF]If[/COLOR] uMsg = WM_SHELLHOOKMESSAGE [COLOR=#0000FF]Then
    5. [/COLOR]        [COLOR=#0000FF]Select[/COLOR] [COLOR=#0000FF]Case[/COLOR] wParam
    6.         [COLOR=#0000FF]Case[/COLOR] HSHELL_WINDOWDESTROYED
    7.         [COLOR=#007A00]'    ShowText "Window Destroyed: " & Hex(lParam)
    8. [/COLOR]        [COLOR=#0000FF]Case[/COLOR] HSHELL_WINDOWCREATED
    9.             [COLOR=#007A00]'ShowText "Window Created: " & Hex(lParam)
    10. [/COLOR]        [COLOR=#0000FF]Case[/COLOR] HSHELL_WINDOWACTIVATED
    11.             [COLOR=#007A00]'lParam contains the handle of the window activated
    12. [/COLOR]            [COLOR=#0000FF]If[/COLOR] lParam > 0 [COLOR=#0000FF]And[/COLOR] lParam <> Me.hwnd [COLOR=#0000FF]Then
    13. [/COLOR]                [COLOR=#007A00]'save handle, threadID and Thread info
    14. [/COLOR]                LastActivehWnd = lParam
    15.                 lastThreadID = GetWindowThreadProcessId(lParam, lastProcessID)
    16.                 [COLOR=#007A00]'now get thread info
    17. [/COLOR]                LastThreadInfo.cbSize = LenB(LastThreadInfo)
    18.                 GetGUIThreadInfo lastThreadID, LastThreadInfo
    19.             [COLOR=#0000FF]End[/COLOR] [COLOR=#0000FF]If
    20. [/COLOR]        [COLOR=#0000FF]End[/COLOR] [COLOR=#0000FF]Select
    21. [/COLOR]    [COLOR=#0000FF]End[/COLOR] [COLOR=#0000FF]If
    22. End[/COLOR] [COLOR=#0000FF]Sub[/COLOR][/FONT]
    Now the only thing left to do is allow the user to start the spell checking by left clicking on the system tray icon that we added. In this code I call a CheckSpelling function that checks the spelling of the text on the clipboard and returns the corrected results to the clipboard.
    VB Code:
    1. [FONT=Courier New][COLOR=#0000FF]Private[/COLOR] [COLOR=#0000FF]Sub[/COLOR] NotifyIcon_Notify(Msg [COLOR=#0000FF]As[/COLOR] [COLOR=#0000FF]Long[/COLOR])
    2.     [COLOR=#0000FF]Dim[/COLOR] strText [COLOR=#0000FF]As[/COLOR] [COLOR=#0000FF]String
    3. [/COLOR]    [COLOR=#0000FF]Select[/COLOR] [COLOR=#0000FF]Case[/COLOR] Msg
    4.     [COLOR=#0000FF]Case[/COLOR] WM_RBUTTONDOWN
    5.         PopupMenu mnMain
    6.     [COLOR=#0000FF]Case[/COLOR] WM_LBUTTONDOWN
    7.         [COLOR=#007A00]'get threadID of LAST ACTIVE WINDOW
    8. [/COLOR]        [COLOR=#0000FF]If[/COLOR] LastActivehWnd > 0 [COLOR=#0000FF]Then
    9. [/COLOR]            [COLOR=#007A00]'prevent changes to data while we work
    10. [/COLOR]            PauseMessages = True
    11.             [COLOR=#0000FF]With[/COLOR] LastThreadInfo
    12.                 [COLOR=#007A00]'set focus back to previous window
    13. [/COLOR]                SetForegroundWindow LastActivehWnd
    14.                 DoEvents
    15.                 Clipboard.Clear
    16.                 [COLOR=#0000FF]If[/COLOR] .hwndCaret > 0 [COLOR=#0000FF]Then
    17. [/COLOR]                    [COLOR=#0000FF]Call[/COLOR] PostMessage(.hwndCaret, WM_COPY, 0&, 0&)
    18.                     hWndEdit = .hwndCaret
    19.                 ElseIf .hwndFocus > 0 [COLOR=#0000FF]Then
    20. [/COLOR]                    [COLOR=#0000FF]Call[/COLOR] PostMessage(.hwndFocus, WM_COPY, 0&, 0&)
    21.                     hWndEdit = .hwndFocus
    22.                 ElseIf .hwndActive > 0 [COLOR=#0000FF]Then
    23. [/COLOR]                    [COLOR=#0000FF]Call[/COLOR] PostMessage(.hwndActive, WM_COPY, 0&, 0&)
    24.                     hWndEdit = .hwndActive
    25.                 [COLOR=#0000FF]Else
    26. [/COLOR]                    PauseMessages = False
    27.                     [COLOR=#0000FF]Exit[/COLOR] [COLOR=#0000FF]Sub
    28. [/COLOR]                [COLOR=#0000FF]End[/COLOR] [COLOR=#0000FF]If
    29. [/COLOR]            [COLOR=#0000FF]End[/COLOR] [COLOR=#0000FF]With
    30. [/COLOR]            DoEvents
    31.             [COLOR=#007A00]'Check for valid Pasted data
    32. [/COLOR]            [COLOR=#0000FF]If[/COLOR] [COLOR=#0000FF]Not[/COLOR] Clipboard.GetFormat(vbCFText) [COLOR=#0000FF]Then
    33. [/COLOR]                Label1 = "[COLOR=#7A0000]No Data from [/COLOR]" & Hex(hWndEdit)
    34.             [COLOR=#0000FF]Else
    35. [/COLOR]                Label1 = Clipboard.GetText
    36.                 [COLOR=#0000FF]If[/COLOR] CheckSpelling [COLOR=#0000FF]Then
    37. [/COLOR]                    SetForegroundWindow LastActivehWnd
    38.                     PostMessage hWndEdit, WM_PASTE, 0&, 0&
    39.                 [COLOR=#0000FF]End[/COLOR] [COLOR=#0000FF]If
    40. [/COLOR]            [COLOR=#0000FF]End[/COLOR] [COLOR=#0000FF]If
    41. [/COLOR]            PauseMessages = False
    42.         [COLOR=#0000FF]End[/COLOR] [COLOR=#0000FF]If
    43. [/COLOR]    [COLOR=#0000FF]End[/COLOR] [COLOR=#0000FF]Select
    44. End[/COLOR] [COLOR=#0000FF]Sub[/COLOR][/FONT]
    Attached is a project that illustrates the technique.
    Attached Files Attached Files

  19. #59
    New Member
    Join Date
    May 2011
    Posts
    1

    Re: Global Hook

    ok so if u have the text that u need to copy allready selected u can copy it to clipboard with sendkeys.send("{^c}') then u can retrieve it with clipboard.gettext how this is what you are looking for

Page 2 of 2 FirstFirst 12

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width