Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Sending keystrokes to non VFP windows
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Fonctions Windows API
Divers
Thread ID:
00158751
Message ID:
00159903
Vues:
79
Hiya Mark,

I got the following to work (thanks to Vlad Tatavu). The only problem that I seem to be having is that if capslock is on when it starts, it's reversed in what it should be. I played with the CAPSLOCK() function in VFP, but for some reason it didn't have the desired impact. Personally, I think there's got to be less in terms of API calls, but haven't had the time to figure it out. As you'll note, this uses my Is_Run32 function from the download section.
#DEFINE KEYEVENTF_KEYUP      2
#DEFINE VK_SHIFT          0x10
DECLARE INTEGER SetForegroundWindow IN Win32API;
  INTEGER hWnd
DECLARE INTEGER SetActiveWindow IN Win32API;
  INTEGER hWnd
DECLARE keybd_event IN Win32API;
  INTEGER bVk, INTEGER bScan,;
  INTEGER dwFlags, INTEGER dwExtraInfo
DECLARE INTEGER ShowWindow IN Win32API;
  INTEGER hWnd, INTEGER uShow
DECLARE INTEGER SetFocus IN Win32API AS SetKeybdFocus;
  INTEGER hWnd
lcsentence = "The quick brown fox jumped over the lazy dogs"
lnhWnd = Is_Run32("Notepad")
IF lnhWnd > 0
  = ShowWindow(lnhWnd, 9)
  = SetActiveWindow(lnhWnd)
  = SetForegroundWindow(lnhWnd)
  = SetKeybdFocus(lnhWnd)
  FOR lni = 1 TO LEN(lcsentence)
    lcchar = SUBSTR(lcsentence, lni, 1)
    llshift = ISUPPER(lcchar)
    lnchar = ASC(UPPER(lcchar))
    IF llshift
      = keybd_event(VK_SHIFT, 0, 0, 0)
    ENDIF
    = keybd_event(lnchar, 0, 0, 0)
    = keybd_event(lnchar, 0, KEYEVENTF_KEYUP, 0)
    IF llshift
      = keybd_event(VK_SHIFT, 0, KEYEVENTF_KEYUP, 0)
    ENDIF
  NEXT
ENDIF
George

Ubi caritas et amor, deus ibi est
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform