Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 01/26/2017 in all areas

  1. trancexx

    OnHungApp handler

    Ever happened to you to have blocked app? Window just stopped responding? In AutoIt there isn't much to do when that happens. Just wait or manually kill your app. Embarrassing for you as coder, surly ...Should be. What about this. I register internal handler and when my app hangs next time, I deal with that the way I like it. Maybe try to unblock it or notice the behavior for the future or simply exit, whatever... This UDF gives you ability to register function to call when app stops responding. Placeholder for the function is defined as (name is irrelevant): Func _OnHungApp($iParam1, $iParam2) EndFunc Parameters are: $iParam1 - lparam DllCall type$iParam2 - wparam DllCall typeSo you can pass whatever you want to the function. Default is 0, 0. Handler works differently depending on what you return from _OnHungApp(). Three possibilities: In case you return $HUNGAPP_EXITHANDLER (0/False) handler will no longer be run. This is also the case if you don't specify any return value.If you return $HUNGAPP_EXITPROCESS (1/True) you will exit the app with the exit code you specified when registering handler. By returning $HUNGAPP_CONTINUEHANDLER (259) handler continues handling.Unregistering and freeing resources is done by _OnHungAppUnRegister() function. It's optional. Handler is very low on requirements. Registering is done after you create your GUI (need that handle) or if your app is GUI-less then pass something like: WinGetHandle(AutoItWinGetTitle())Function definition is: _OnHungAppRegister($hWnd, $sFunction[, $iInterval = Default[, $vParam1 = Default[, $vParam2 = Default[, $iExitCode = Default]]]])Description for parameters: $hWnd - A handle to the window to be monitored. $sFunction - Function to call when 'not responding' state is detected. $iInterval - Optional time interval in which to repeat the tesing. Default is 1000 ms (1sec). $vParam1 - Optional parameter to pass to the function (lparam). Default is 0. $vParam2 - Optional parameter to pass to the function (wparam). Default is 0. $iExitCode - Optional exit code for the app to return. Default is 0. Another function is _OnHungAppRegisterEx. That one works slightly different. The benefits are that you can choose time value at which _OnHungApp() will be called. This is more advanced approach since you are in complete control. That one is defined as: _OnHungAppRegisterEx($hWnd, $sFunction[, $iHungAppTime = Default[, $vParam1 = Default[, $vParam2 = Default[, $iExitCode = Default]]]])Parameters: $hWnd - A handle to the window to be monitored. $sFunction - Function to call when 'not responding' state is detected. $iHungAppTime - Optional time value in ms at which window will be flagged as unresponding one. Default is 5000 ms. Minimum is 500 ms. $vParam1 - Optional parameter to pass to the function (lparam). Default is 0. $vParam2 - Optional parameter to pass to the function (wparam). Default is 0. $iExitCode - Optional exit code for the app to return. Default is 0. $iInterval - Optional time interval in which to repeat the tesing. Default is 250 ms. Script with few examples: OnHungApp.zip
    1 point
  2. HotKeySet("^{F12}","test") ; - Trigger test() when ctrl+F12 is pressed While True Sleep(100); Continue running script WEnd Func test() MsgBox(0,"","hello") EndFunc
    1 point
  3. Starf0x

    Shell Execute

    Try this: While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 Call("Run") EndSwitch WEnd Func Run() ShellExecute ("Masen's Headquarter Interface.exe","", "C:\Users\masen\Desktop\HQ-General" ,"open", @SW_MAXIMIZE) EndFunc You've added Exit after you clicked the "Home" Button. Cheers, Starf0x
    1 point
  4. Melba23

    Shell Execute

    Masen, The third parameter is the working directory, not the full path and name of the executable. Try changing the line to read: ShellExecute ("Masen's Headquarter Interface.exe","", "C:\Users\masen\Desktop\HQ-General" ,"open","@SW_MAXIMIZE") M23
    1 point
  5. 1 point
  6. Yo dgm5555, What I found here is eeeeexcelent piece of code that fits perfectly my needs. I tried Tesseract, Sikuli, and searched for several days to get recognition rate up but never succeded, this works out of the box with 100% accuracy (due to inbuilt training). THANK YOU SO MUCH, give me your paypal address so I can buy you a pack of beers! PS: When I run OCR with $ocrOptDontSaveWindowWithFont, program fails because its only setting $saveWindowForFont in case its not set. Adding $saveWindowForFont = "" just before If NOT BitAND($ocrOptions, $ocrOptDontSaveWindowWithFont) Then $saveWindowForFont = @TAB & WinGetTitle("[ACTIVE]") works nicely
    1 point
×
×
  • Create New...