1. Reactivate my application * * Get window handle: * SET LIBRARY TO foxtools.fll whnd = mainhwnd() SET LIBRARY TO * Stuff that might make another application active here... * * Restore me to the foreground, active window: * DECLARE Integer SetForegroundWindow in WIN32API long whnd x = SetForegroundWindow(whnd) 2. procedure init thisform.label1.caption=alltrim(str(reccount("canton")))+" words" Declare integer SetForegroundWindow in Win32Api integer Declare integer FindWindow in Win32Api string, string Local wHandle With this wHandle = FindWindow(0,this.caption) SetForeGroundWindow(wHandle) Endwith clear dlls endproc 3. FUNCTION DetectProcess(lcProcess) lcComputer = '.' loWMIService = Getobject('winmgmts:' ; + '{impersonationLevel=impersonate}!\\' + lcComputer + '\root\cimv2') colProcessList = loWMIService.ExecQuery ; ('Select * from Win32_Process') For Each loProcess In colProcessList IF UPPER(loProcess.name) = lcProcess ** Do something here endif Next 4. hide windows start menu: loForm = CREATEOBJECT("Form") DECLARE SetParent IN user32 integer hWndChild, integer hWndParent DECLARE LONG FindWindow IN "user32" STRING lpClassName, STRING lpWindowName DECLARE LONG FindWindowEx IN "user32" LONG hWnd1, LONG hWnd2, STRING lpsz1, STRING lpsz2 taskbarHwnd = FindWindow("Shell_TrayWnd", "") startbuttonHwnd = FindWindowEx(taskbarHwnd, 0x0, "Button", .NULL.) * loForm is not visible... hide taskbar SetParent(taskbarHwnd, loForm.hwnd) MESSAGEBOX("duh") * set it back please SetParent(taskbarHwnd, 0) * hehehehe SetParent(startbuttonHwnd, loForm.hwnd) loForm.show MESSAGEBOX("duh") * hmmm SetParent(startbuttonHwnd, 0) MESSAGEBOX("duh") * now I know a way how to hide the startbutton and put it back afterwards * http://www.foxite.com/foxitehelplib/faq900425.htm only shows us how to kill the button SetParent(startbuttonHwnd, taskbarHwnd) 5. Push a key: * from winuser.h #define WM_KEYDOWN 0x100 #define WM_KEYUP 0x101 #define WM_CHAR 0x102 Declare integer FindWindow in Win32Api string, string DECLARE INTEGER SendMessage IN user32; INTEGER hWnd,; INTEGER Msg,; INTEGER wParam,; INTEGER lParam Declare integer FindWindow in Win32Api string, string Local wHandle wHandle = FindWindow(0,"Microsoft Visual FoxPro") ? sendmessage(wHandle, WM_CHAR, asc("A"), 1) clear dlls 6. lcInPath = sys(2023) lcOutPath = space(260) declare integer GetLongPathName in kernel32 ; string lpszShortPath, ; string @lpszLongPath, ; integer cchBuffer lnLen = GetLongPathName( lcInPath, @lcOutPath, len( lcOutPath ) ) ? left( lcOutPath, lnLen ) 7. declare integer ExpandEnvironmentStrings in Kernel32.dll ; string @lpSrc, string @lpDst, integer Size *-------------------------------------------------------------------------- function ExpandEnvStrings(s) local i, s1 s1 = space(1024) i = ExpandEnvironmentStrings(@m.s, @m.s1, 1024) return left(m.s1, m.i-1) endfunc 8. local RegEx, Match, s, i RegEx = CreateObject('VBScript.RegExp') RegEx.Global = TRUE RegEx.Pattern = '\b\d{4}[- ]?\d{4}[- ]?\d{4}[- ]?\d{4}\b' s = 'aa2345-8493-9385-2873' ; && no match, ie no word boundary + CRLF + 'aa 1345-8493-9385-2873' ; + CRLF + repl('2',16) ; + CRLF + '9999 9999 9999 9999' Match = RegEx.Execute(m.s) for i = 0 to Match.Count - 1 ? 'Match ', transf(m.i), '<'+ Match.Item[m.i].Value+'>', ' at', Match.Item[m.i].FirstIndex + 1, 'len ', Match.Item[m.i].Length endfor 9. Declare integer GetForegroundWindow in WIN32API Declare short IsWindow in WIN32API integer lnHwndActiveX = GetForegroundWindow()?&& Save window handle Do while IsWindow(lnHwndActiveX) # 0?&& Wait while ActiveX Alive Enddo 10. Kill process IF KillApp("A Window Title") * replace "A Window Title" with the title of the app that you want to close ?"app killed" ELSE ?"app still alive..." ENDIF FUNCTION KillApp LPARAMETER tcCaption LOCAL lnWinHandle, lnRetval, lnResult, llRetval DECLARE INTEGER WaitForSingleObject IN Win32API ; INTEGER hHandle, ; INTEGER dwMilliseconds DECLARE INTEGER FindWindow IN Win32API ; STRING lpClassName, ; STRING lpWindowName DECLARE INTEGER PostMessage IN Win32API ; INTEGER hwnd, ; INTEGER wMsg, ; INTEGER wParam, ; INTEGER lParam DECLARE INTEGER IsWindow IN Win32API ; INTEGER hwnd #DEFINE WM_CLOSE 16 && H10 #DEFINE INFINITE 4294967295 && HFFFFFFFF lnWinHandle = FindWindow(0, tcCaption) lnRetval = PostMessage(lnWinHandle, WM_CLOSE, 0, 0) lnResult = WaitForSingleObject(lnWinHandle, INFINITE) llRetval = (IsWindow(lnWinHandle) = 0) RETURN llRetval ENDFUNC 12. End Task This may be of help (something I've used plenty of times (works like a charm)): DECLARE EndTask IN user32 INTEGER hwnd, INTEGER fShutDown, INTEGER fForce =EndTask(_Screen.HWND,0,1) 13. Terminal service? FUNCTION IsTerminalClient #DEFINE sm_RemoteSession 4096 DECLARE INTEGER GetSystemMetrics IN User32.dll INTEGER return GetSystemMetrics(sm_RemoteSession)=1 13. Declare Integer GetLongPathName in Win32API ; String, String @, Integer lcBuffer = Replicate(Chr(0),256) lcPath = GetEnv("TEMP") GetLongPathName(lcPath, @lcBuffer, 256) ? Chrtran(lcBuffer,Chr(0), '')