Jump to content
Sign in to follow this  
Ascend4nt

Full-Screen Crash Recovery 1.0

Recommended Posts

Ascend4nt

Full-Screen Crash Recovery 1.0

Crashed programs or games with screens that won't go away? Ctrl-Alt-Del, Alt-F4, Alt-Tab, and the Windows Key not working for ya? Do you find that you can 'almost' just get out of a game screen, but see constant flicker and only parts of the Windows desktop or mouse pointer?

Want a fix for all that crap? Here it is. This bad boy will drop that program and kick it to the curb. public/style_emoticons/autoit/laugh.gif =P

So what's it all about? This program uses Yashied's 'HotKey.au3' UDF to track keypresses and looks for this combo:

Shift-Alt-Del (easy enough to remember eh?)

Once you press that combo, my program will kick in and start analyzing the Windows on the screen - finding at most two windows that have full-screen or maximized status (there is a difference in Window's world). If the *active* window is the one that matches those criteria, it is chosen as the 'target' (otherwise, the first found non-Explorer window will be the target).

Now, I'm all about safety (preventing accidents) - but I'm also all about killing something if it's really crashed.

So what my program does on each hotkey press is this:

  • On the 1st Shift-Alt-Del press, the program determines if the 'target' Window it finds is Hung/Crashed using a quick method. If Window reports that it is - it's killed on the spot, and the cycle resets. If not, it will save the 'target' info for the proceeding hotkey presses.
  • On the 2nd Shit-Alt-Del press, the program will look again through the Window list. If it finds the same 'target', it will again check if the program is Hung/Crashed or Suspended (if so, kill & reset). This process can take up to 5 seconds, especially for a suspended app. Now, since the app was found twice, and is responding to messages, my program will attempt to alter a window's 'Always-on-Top' status and Minimize it. Sometimes (!!) this may solve the case (other times, not-so-much).
  • On the 3rd Shift-Alt-Del press, the program will search again as above, compare the window to the last one, and if it's the same, and still in full-screen/maximized state, it will finally say 'screw it', and just terminate the application.
At each step, you'll get a speaker Beep confirmation (if you don't have an internal PC speaker, you can alter the Beeps to 'SoundPlay()' or somesuch). In any case, the Beeps are like this. (thanks montymintypie for suggesting this):

  • low beep = no window found in maximized/full-screen status
  • high beep = window found, but Windows isn't reporting it is hung
  • dual-tone beeps (mid-then-high) = Window terminated.
In addition, if the hotkey to close the app down is pressed, you'll get a reverse dual-tone-beep (high-low) meaning its shut down. By the way, that hotkey is:

Shift-ALT-Q (terminate my program)

The reason for this 'third-times-a-charm' thinking is that:

  • You want to be sure that you really wanted to close that app (if for some reason Windows reports the app as crashed though, there's no 2nd or 3rd time),
  • Sometimes minimizing actually does work, and
  • If you were able to close/minimize the application, and switched to another and maximized/full-screened it, the code will recognize that the screen is no longer in that maximized/full-screen state, and simply reset its internal variables (and the HotKey-press count will reset to 0)
NOTES:

  • Any window owned by Explorer.exe process will be IGNORED, with the exception that if explorer.exe itself has crashed (and pulled other windows into its vortex), it will allow it to be terminated (and then restarted). But under typical circumstances, it will differentiate the Explorer Windows from regular Application/Game windows, and by doing so, prevent accidental closure of the main Windows interface!
  • As stated above, any time the same app is not found to be minimized, it will reset the internal count and variables, so the HotKey-press count will reset to 0.
Get it now at http://sites.google.com/site/ascend4ntscode/fullscreencrashrecovery

A list of the major enhancements/changes since I started (prior to v. 1.0!):

  • Added two methods for detecting if an application is hung/crashed/suspended
  • Rewrote a LOT of the code based on my own experiences with crashes (both in XP and Vista, applications and games)
  • Separated functions to make it easier to understand and centralized Debug messages in case you'd like to output them to a log.
  • Rewrote the main function AGAIN, due to certain Win..() functions in AutoIT failing to work on crashed applications

    (I've remarked about these functions and my experiences with them in the source code right under the header)

  • Added better 'beep-notifications' (thanks to montymintypie for getting me to do that)
Ascend4nt's Program License agreement:

While I provide this program freely, if you do distribute the program, the only requirements I have are:

  • I (Ascend4nt) must be Acknowledged as the author
  • The License agreement document (in the ZIP file) must be kept bundled together with the code.
  • A link must be provided to the page containing the program (linked above)
  • Do *not* under any circumstances 'reverse-engineer' the code - in other words, do not pull out the source code. I may distribute the source code in the future - but if you have or find an old copy of my code, do not distribute it without my consent, which must be obtained through the 'ContactMe' page on this site.
Edited by Ascend4nt

Share this post


Link to post
Share on other sites
Manko

That API "IsHungAppWindow" is a great find! (I like your implementation too!)

I've been using "SendMessageTimeout" to find out if the messagehandler is stuck, app is locked...

Think I'll have to try your function out instead! :D

/Manko


Yes i rush things! (I sorta do small bursts inbetween doing nothing.) Things I have rushed and reRushed:* ProDLLer - Process manager - Unload viri modules (dll) and moore...* _WinAPI_ProcessListOWNER_WTS() - Get Processes owner list...* _WinAPI_GetCommandLineFromPID() - Get commandline of target process...* _WinAPI_ThreadsnProcesses() Much info if expanded - optional Indented "Parent/Child"-style Processlist. Moore to come... eventually...

Share this post


Link to post
Share on other sites
insignia96

2. On the 2nd Shit-Alt-Del press, the program will look again for the full screen/maximized window (starting with the Active one), and see if it's the same as the one found on the 1st HotKey-press. If yes, the program sends a 'Minimize Window' command to the window. Sometimes this may solve the case, other times note.

I must admit, that is the best typo i've seen all day! Nice script tho! i will use it!


Visit my website to see all my finished releases!Releases here:UDFs:GUI ResizingColor List (Web Colors)GUIFade_NearestPower

Share this post


Link to post
Share on other sites
Ascend4nt

That API "IsHungAppWindow" is a great find! (I like your implementation too!)

I've been using "SendMessageTimeout" to find out if the messagehandler is stuck, app is locked...

Think I'll have to try your function out instead! :D

/Manko

Manko, your method is probably the preferred way, as MSDN says the 'IsHungAppWindow' API call 'might be altered or unavailable in subsequent versions of Windows'. But hey, they say that for a number of functions don't they? And I say that MSDN should be held responsible for supporting the functions they put up documentation for, darnit! But hey - you're method might be more 'recommended', and I didn't even think to look for alternatives until I looked at the documentation for what you mentioned hehe.

Either way, like I said in my testing - it has never reported an App as hung. I'd like to know if it actually ever does!

Share this post


Link to post
Share on other sites
Ascend4nt

Updated the program:

*EDIT: changed the behavior slightly - if the DLLCall fails, it doesn't just beep and return immediately - it now continues on to check the '$iAttemptedKillCount' variable (and work as reported above). The change was made just in case the DLLCall consistently fails.

Btw, thx insignia96 (for both the compliment and the typo spot! hehe)

Share this post


Link to post
Share on other sites
Manko

Either way, like I said in my testing - it has never reported an App as hung. I'd like to know if it actually ever does!

It should be easy to test. If you have a graphical autoit using only GUIGetMsg method for its messagehandling...

...instead of handling incomeing messages and quickly calling it again, put an endless loop in... :D

...or just use my app to suspend some grahical app, test it with your function, and u should get results. :D

/Manko


Yes i rush things! (I sorta do small bursts inbetween doing nothing.) Things I have rushed and reRushed:* ProDLLer - Process manager - Unload viri modules (dll) and moore...* _WinAPI_ProcessListOWNER_WTS() - Get Processes owner list...* _WinAPI_GetCommandLineFromPID() - Get commandline of target process...* _WinAPI_ThreadsnProcesses() Much info if expanded - optional Indented "Parent/Child"-style Processlist. Moore to come... eventually...

Share this post


Link to post
Share on other sites
Ascend4nt

It should be easy to test. If you have a graphical autoit using only GUIGetMsg method for its messagehandling...

...instead of handling incomeing messages and quickly calling it again, put an endless loop in... :D

...or just use my app to suspend some grahical app, test it with your function, and u should get results. :D

/Manko

Unfortunately, creating a graphical AutoIT program like you said still responds to messages, even with SendMessageTimeOut. I've even disabled the minimize/maximize boxes and did all sorts of wonky things, but to no avail!

I did happen to use your great ProDLLer app, as well as Advanced Process Termination to 'Suspend' apps. By doing this, I found out that I had to do a lot of rewriting!

Turns out that WinGetTitle() and WinSetState() (@SW_MINIMIZE) on a suspended app will cause my program to just sit there waiting for those functions to return (which they won't, until the application is finally unsuspended).

Oh, and 'IsHungAppWindow' always returned False - though I don't know if there's a distinction between a 'hung' application and a 'suspended' one. I *still* need to find a program running full-screen that crashes so that I can find out for certain! I think I know of one person who has a crash at a specific point in time in some game.. I'll need to go over someday and try my program out.

So anyway, I'll be posting new code shortly that should solve every conceivable problem ;)

Share this post


Link to post
Share on other sites
Ascend4nt

New update:

*EDIT 2: rewrite of much of the code. No longer locks up for 'Suspended' applications, and also now attempts a 2nd method of detecting if an app has crashed (Note: this will take about 5 seconds if the given app truly isn't responsive, but will definitely terminate it [2nd method happens on 2nd Hotkey-press]). Also a little more debug info is written to the console (you can disable these calls if you like).

Share this post


Link to post
Share on other sites
montymintypie

I'm in OS X at the moment, so I can't test this.

Sometimes TF2 or Gmod will crash, and if I do Ctrl-Alt-Del the mouse cursor will change as I roll over parts of the Task Manager window, but I can still only see the crashed game window, with a freeze frame of the last rendered game frame. This helps with this, right? So, if I encounter this, I press the shortcut a few times until it quits? Because that sounds like a REALLY good idea. I'll download this and see how it goes next time I run a game. If it works, it's definitely going in my start-up items. :-D

Will T

Share this post


Link to post
Share on other sites
Ascend4nt

montymintypie,

That's EXACTLY the type of situation I made this for! (only, after making it, I forgot what friggin programs & games were doing that to me! haha :D ) So yes, please please test it! :D And if you can do me a favor, let me know what the debug output is (run it through Scite, or I can give u a simple output-redirector program I wrote so we can gather the output)

A couple of reminders - between Shift-Alt-Delete presses, you must release ALL three keys before pressing them again. And just hold it for like 2/10ths of a second (due to the sleep in the loop). Oh, and make sure the _AsyncHotKeySet UDF is in the same folder (or just paste it all at the beginning of the script if you're just experimenting).

(I may consider putting this all in a zip since I'm starting to realize how big a pain it would be for people to grab all the code I do #include's on, and paste them into scripts..)

Share this post


Link to post
Share on other sites
montymintypie

I've been busy recently, haven't been playing many games, so I might not be able to give results too soon...

I've set it so scripts open in SciTe by default, so it'll open in there anyway. :D

If this thread is old enough to be 'dead' by the time a game crashes for me, I'll just PM you.

Will

Share this post


Link to post
Share on other sites
Inverted

Isn't this overkill ? :D

I have a Logitech G15 and have assigned these 2 compiled scripts to 2 of the macro buttons :

First terminates the active window :

ProcessClose(WinGetProcess ("[active]"))ProcessClose(WinGetProcess ("[active]"))oÝ÷ Ù'¢w]¡ë~ÜyÚÞn-jëh×6ShutDown (2+4+16)

Share this post


Link to post
Share on other sites
Ascend4nt

Inverted,

Overkill? No, but I'd have to say that I'd never assign those type of macros to mouse or joystick buttons, all without checking if the application isn't hung.

In addition:

  • What if you accidentally press the button? Oops, I killed the game that was working fine? (or, woopsie,I accidentally rebooted and killed everything?!) That seems like going a bit too far to me :D
  • What if the crashed game/app isn't the active window? (this happens sometimes if you actually switch windows (for example, using Ctrl-Alt-Del or Alt-Tab). You could actually wind up closing Windows explorer by accident. (The applications that I've come across that crash badly typically don't let you even *see* the other screen, let alone know what the 'active' window is if you tried to switch)
  • And in addition to that - WinGetProcess ("[active]") returns a seemingly random # for programs that are suspended (just tested), while WinGetHandle("[ACTIVE]") returns 0. I'm *guessing* these results might be the same for crashed apps - so in effect you'd be closing an invalid or incorrect process. Not a good move..

(*edit: just tested WinGetProcess ("[active]") on suspended apps, so adjusted 3rd point to reflect that)

Edited by ascendant

Share this post


Link to post
Share on other sites
JSThePatriot

I still play Renegade on occasion, and it will lock up in a manner that only a cold boot will help the situation. This is quite annoying as I have to wait for the computer to boot to get back into the game. Will be trying this script on my desktop at the house.

Thanks,

Jarvis


AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Share this post


Link to post
Share on other sites
Ascend4nt

New version:

*EDIT 3: modified to work with HotKey.au3, also modified one of the DLLCall @error checks

@JSThePatriot: Any feedback on how well it works (along with the log info if you run it from Scite) would be much appreciated :)

Share this post


Link to post
Share on other sites
JSThePatriot

I haven't had a crash yet... I'll keep you posted.

Jarvis


AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Share this post


Link to post
Share on other sites
montymintypie

I tried to test using the Gmod loading screen, as it seems frozen (but is just loading). Instead, it successfully minimised the window. Actually a good thing! Here's the console output:

Found window matching criteria, Maximized status=False, Alternative Full-Screen test result=True...
Checking if window 'Garry's Mod' (process ID #5792) is 'hung'...
SendMessageTimeoutW (WM_GETTEXT msg) return succeeded, text return = 'Garry's Mod'
2nd attempted Kill command received. Sent 'Minimize-window' command to window..

Also, I'm using my Mac in BootCamp, and I don't hear a beep. Any other way to give me audio confirmation?

This is the first time I've wanted a game to crash... :)

Will

Share this post


Link to post
Share on other sites
Ascend4nt

montymintypie,

a Mac? How the heck are you running the program? A virtual machine? And what's BootCamp?

You could probably replace Beep() with SoundPlay(), assuming you have a sound to play, and it works on whatever weird config you have :)

Share this post


Link to post
Share on other sites
montymintypie

montymintypie,

a Mac? How the heck are you running the program? A virtual machine? And what's BootCamp?

You could probably replace Beep() with SoundPlay(), assuming you have a sound to play, and it works on whatever weird config you have :)

BootCamp basically means I boot in Windows instead of Mac. It's just like having a PC. Great for games!

I used Audacity to replicate the beeps, then saved them as wavs and used the SoundPlay() function. It's good to know if the program is doing something! Still haven't crashed a game yet...

Share this post


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
Sign in to follow this  

  • Similar Content

    • SuleymanTopaloglu
      By SuleymanTopaloglu
      Hello i am new here and this is my first thread
      in this script i used some code snippets from forum.
      I do not remember who these belonged to.
      Disabled
      ALT+F4
      ALT+TAB
      TASK MANAGER
      LOCKING WINDOWS
      deleted items from ctrl+alt+delete screen
      (Lock Computer,Switch User,Sign Out,Chance a password,Task Manager)
       
      CTRL+ALT+DELETE (how ?)
      firstly we are disabled locking computer
      RegWrite('HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System', 'DisableLockWorkstation',"REG_DWORD",0x00000001) and then ctrl+alt+delete pressed IsDesktopLocked() triggered.
      we are calling  
      Run("rundll32.exe user32.dll,LockWorkStation") command with checking if $blockctrlaltdel = 1 statements. 
      then it return us to kiosk screen, because we are disabled locking computer. 
       
      Func IsDesktopLocked() Local $hDesktop Local $iRet Local $iRC Local $sMsg Local Const $DESKTOP_SWITCHDESKTOP = 0x100 $hDesktop = DllCall("User32.dll", "int", "OpenDesktop", "str", "Default", "int", 0, "int", 0, "int", $DESKTOP_SWITCHDESKTOP) $iRet = DllCall("User32.dll", "int", "SwitchDesktop", "int", $hDesktop[0]) If IsArray($iRet) Then If $iRet[0] = 0 Then if $blockctrlaltdel = 1 Then Run("rundll32.exe user32.dll,LockWorkStation") EndIf $iRC = 1 ElseIf $iRet[0] = 1 Then $iRC = 0 EndIf Else EndIf DllCall("User32.dll", "int", "CloseDesktop", "int", $hDesktop[0]);<-- handle returned by "OpenDesktop" ;$iRet = DllCall("User32.dll", "int", "CloseDesktop", "int", $iRet[0]) Return ($iRC) EndFunc ;==>IsDesktopLocked maybe this blocked to lock computer when rdp session closed. i havent tried and This script needed to Google chrome and "WinLockDll.dll" to work. 
      FULL SCRIPT
       
      #include <WinAPI.au3> #include <FontConstants.au3> #include <GUIConstants.au3> Opt('GUIOnEventMode', 1) Opt("TrayAutoPause", 0) HotKeySet("{ESCAPE}","_EXIT") ;~ $sFilePath = "D:\kiosk\" local $Form1,$blockctrlaltdel Global Const $VK_F4 = 0x73 Global $winlockdll = DllOpen(@ScriptDir&"\WinLockDll.dll") kullanimkapat() #region ; WinEventHook Global Const $EVENT_OPEN_DESKTOP_CHANGED = 0x0020 $h_DLL_User32 = DllOpen("User32.dll") $h_WinEventHook_Proc = DllCallbackRegister("_WinEventHook_Proc", "none", "hwnd;int;hwnd;long;long;int;int") If @error Then ConsoleWrite("Error DllCallbackRegister(_WinEventHook_Proc) did not succeed. FFH will exit now.") Exit EndIf $h_Hook = _WinEventHook_Set(0x0020, 0x0020, $h_DLL_User32) If @error Then ConsoleWrite("Error _WinEventHook_Set() did not succeed. FFH will exit now.") Exit EndIf OnAutoItExitRegister("_WinEventHook_UnSet") #endregion ; WinEventHook Global $winlockdll = DllOpen(@ScriptDir&"\WinLockDll.dll") Func kullanimkapat() $blockctrlaltdel = 1 Global $hHookProc = DllCallbackRegister("_KeyboardProc", "long", "int;wparam;lparam") Global $hHookKeyboard = _WinAPI_SetWindowsHookEx($WH_KEYBOARD_LL, DllCallbackGetPtr($hHookProc), _WinAPI_GetModuleHandle(0), 0) Global $hSysTray_Handle = DllCall("user32.dll", "HWND", "FindWindow", "str", "Shell_TrayWnd", "str", "") _WinAPI_ShellChangeNotify($SHCNE_ASSOCCHANGED, 0, 0, 0) _SendMessage($hSysTray_Handle[0], 0x5B4, 0, 0) DllCall($winlockdll, "Int", "Keys_Enable_Disable ", "Int", "1") DllCall($winlockdll, "Int", "TaskManager_Enable_Disable", "Int", "0") DllCall($winlockdll, "Int", "TaskSwitching_Enable_Disable", "Int", "0") DllCall($winlockdll, "Int", "Keys_Enable_Disable", "Int", "1") RegWrite('HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System', 'DisableChangePassword',"REG_DWORD",0x00000001) RegWrite('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System', 'HideFastUserSwitching', "REG_DWORD",0x00000001) RegWrite('HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer', 'NoLogoff',"REG_DWORD",0x00000001) RegWrite('HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer', 'NoClose',"REG_DWORD",0x00000001) RegWrite('HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System', 'DisableTaskMgr',"REG_DWORD",0x00000001) RegWrite('HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System', 'DisableLockWorkstation',"REG_DWORD",0x00000001) FileDelete ( @LocalAppDataDir&"\Google\Chrome\User Data\Default\Preferences" ) ;~ Local $hFileOpen = FileOpen($sFilePath,BitOR(8,2)) ;~ FileWrite($hFileOpen,'<!DOCTYPE html><meta http-equiv="refresh" content="30"><html><head><script type="text/javascript">function disableselect(e){return!1}function reEnable(){return!0}document.onselectstart=new Function("return false"),document.oncontextmenu=new Function("return false"),window.sidebar&&(document.onmousedown=disableselect,document.onclick=reEnable);</script><style>#masano{top:50%;left:50%;width:250px;height:250px;margin-top:-125px;margin-left:-125px;border:1px solid red;background-color:red;position:fixed;font:normal 200px Calibri;line-height:250px;text-align:center;color:white}</style><title>*</title></head><body><div id="masano">'&@ComputerName&'</div></body></html>"') ;~ FileClose($hFileOpen);kiosk html writed Run("taskkill /im chrome.exe /f /t") Sleep(3000) ;~ Run(@HomeDrive&"\Program Files (x86)\Google\Chrome\Application\chrome.exe --kiosk "&$sFilePath) Run(@HomeDrive&"\Program Files (x86)\Google\Chrome\Application\chrome.exe --kiosk https://www.autoitscript.com/autoit3/files/graphics/autoit_10_wall_1920x1200.jpg") WinMinimizeAll() Global $hSplash = GuiCreate("", @DesktopWidth+5, @DesktopHeight+5, -5, -5,$WS_POPUP,$WS_THICKFRAME) ;invinsible fullscreen gui on top google chrome. GUISetBkColor (0xf0f8ff) WinSetTrans($hSplash, "", 5) GUISetState() WinSetOnTop($hSplash, "", 1) EndFunc Func kullanimAc() FileDelete ( @LocalAppDataDir&"\Google\Chrome\User Data\Default\Preferences" ) $blockctrlaltdel = 0 DllCallbackFree($hHookProc) If Not IsHWnd($hSysTray_Handle[0]) Then ShellExecute(@WindowsDir & "\Explorer.exe") DllCall($winlockdll, "Int", "Keys_Enable_Disable ", "Int", "0") DllCall($winlockdll, "Int", "TaskManager_Enable_Disable", "Int", "1") DllCall($winlockdll, "Int", "TaskSwitching_Enable_Disable", "Int", "1") DllCall($winlockdll, "Int", "Keys_Enable_Disable ", "Int", "0") RegDelete('HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System','DisableChangePassword') RegDelete('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System', 'HideFastUserSwitching') RegDelete('HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer', 'NoLogoff') RegDelete('HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer', 'NoClose') RegDelete('HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System', 'DisableTaskMgr') RegDelete('HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System', 'DisableLockWorkstation') Run("taskkill /im chrome.exe /f /t") Sleep(500) GUIDelete($hSplash) Sleep(500) EndFunc Func _KeyboardProc($nCode, $wParam, $lParam) If $nCode < 0 Then Return _WinAPI_CallNextHookEx($hHookKeyboard, $nCode, $wParam, $lParam) Switch $wParam Case $WM_KEYDOWN, $WM_SYSKEYDOWN, $WM_KEYUP, $WM_SYSKEYUP Local $tKEYHOOKS = DllStructCreate($tagKBDLLHOOKSTRUCT, $lParam) Local $vKode = DllStructGetData($tKEYHOOKS, "vkCode") Local $iFlags = DllStructGetData($tKEYHOOKS, "flags") Switch $vKode Case $VK_F4 If BitAND($iFlags, $LLKHF_ALTDOWN) Then Return -1 Else Return _WinAPI_CallNextHookEx($hHookKeyboard, $nCode, $wParam, $lParam) EndIf EndSwitch EndSwitch Return _WinAPI_CallNextHookEx($hHookKeyboard, $nCode, $wParam, $lParam) EndFunc #region ; WinEventHook Functions Func _WinEventHook_Proc($h_Hook, $iEvent, $hWnd, $idObject, $idChild, $iEventThread, $iEventTime) ;ConsoleWrite($hWnd & @TAB & $idObject & @CRLF) ConsoleWrite(TimerInit() & @tab & hex($iEvent,4) & @tab & "IsDesktopLocked()" & @tab & IsDesktopLocked() & @crlf) EndFunc ;==>_WinEventHook_Proc Func _WinEventHook_Set($iEventMin, $iEventMax, $hDLLUser32) Local $aRet Local Const $WINEVENT_OUTOFCONTEXT = 0x0 Local Const $WINEVENT_SKIPOWNPROCESS = 0x2 If Not $hDLLUser32 Or $hDLLUser32 = -1 Then $hDLLUser32 = "User32.dll" $aRet = DllCall($hDLLUser32, "hwnd", "SetWinEventHook", _ "uint", $iEventMin, _ "uint", $iEventMax, _ "hwnd", 0, _ "ptr", DllCallbackGetPtr($h_WinEventHook_Proc), _ "int", 0, _ "int", 0, _ "uint", $WINEVENT_OUTOFCONTEXT) ; BitOR($WINEVENT_OUTOFCONTEXT, $WINEVENT_SKIPOWNPROCESS) If @error Then Return SetError(@error, 0, 0) Return $aRet[0] EndFunc ;==>_WinEventHook_Set Func _WinEventHook_UnSet() If $h_WinEventHook_Proc Then DllCallbackFree($h_WinEventHook_Proc) EndIf If $h_Hook Then DllCall($h_DLL_User32, "int", "UnhookWinEvent", "hwnd", $h_Hook) If $h_DLL_User32 Then DllClose($h_DLL_User32) EndFunc ;==>_WinEventHook_UnSet #endregion ; WinEventHook Functions Func IsDesktopLocked() Local $hDesktop Local $iRet Local $iRC Local $sMsg Local Const $DESKTOP_SWITCHDESKTOP = 0x100 $hDesktop = DllCall("User32.dll", "int", "OpenDesktop", "str", "Default", "int", 0, "int", 0, "int", $DESKTOP_SWITCHDESKTOP) $iRet = DllCall("User32.dll", "int", "SwitchDesktop", "int", $hDesktop[0]) If IsArray($iRet) Then If $iRet[0] = 0 Then if $blockctrlaltdel = 1 Then Run("rundll32.exe user32.dll,LockWorkStation") EndIf $iRC = 1 ElseIf $iRet[0] = 1 Then $iRC = 0 EndIf Else EndIf DllCall("User32.dll", "int", "CloseDesktop", "int", $hDesktop[0]);<-- handle returned by "OpenDesktop" ;$iRet = DllCall("User32.dll", "int", "CloseDesktop", "int", $iRet[0]) Return ($iRC) EndFunc ;==>IsDesktopLocked Func _EXIT() kullanimAc() HotKeySet("{ESCAPE}") Exit EndFunc While 1 Sleep(100) WEnd  
      WinLockDll.dll
       
      pc-kilitle.au3
    • TheSaint
      By TheSaint
      An adaption of an adaption.
      A good while back, I created a program, KindEbook Wishlist, that I use most days and is still available here at the forum. It works well, keeping tabs on price changes for Kindle ebooks at Amazon ... at least for my modest wants.
      About a year or so later, I struck upon the idea of adapting that program for CDs, DVDs, Blu-rays etc from the JB Hifi store, where there was a limit of about 50 items on the in-store wishlist. JB Wishlist is kind of a niche program, really only suitable for those from AUS, at the AutoIt Forum, who would want such a thing ... so not many I imagine, so it has never been available here. However, if you meet that criteria etc, and are willing to register at the AutoIt4Life Clubrooms, then it is available in the Project Chat section there ... though not the more recent updates (you need to ask me about them). That too, works quite well for my modest needs, and even includes an additional Preview & Summary window, which KindEbook Wishlist doesn't have ... though both programs do have access to a Details window per item, that is like the Preview window ... just doesn't constantly display alongside the Main program window (see later for an example with IonGoG Wishlist).
      So, now we come to IonGoG Wishlist, which is an adaption of the JB Wishlist program, and used for keeping tabs on GOG Games ... prices, history of changes, bought list, etc.
      IonGoG Wishlist is an incomplete adaption, so still in beta ... though all the really important elements work well enough. I have been working on it in dribs and drabs, and I now think it has come to a reasonable enough stage to share it ... just be advised, that some of the features accessed via the right-click menu etc, may not work or give strange results. Any of the options that I have given an Accelerator key facility to, should be working fine ... and most of the others are too ... and I am not even sure at this point, of what remains to be adapted ... not much I imagine.
      The name by the way, in case you were wondering, is a phonetic mangling on the words - keep an Eye On your GOG Wishlist.
      Here is a screenshot, with the Preview window on left. The Preview window can be placed at right instead or even turned off.

      Download, includes source files.
      IonGoG Wishlist v0.0_b14.zip  (see detail at Post #10)
      Enjoy!
      OLDER DOWNLOADS
      SUPPLEMENTARY
      I have another program that GOG users may be interested in, that can assist with getting game images that IonGoG Wishlist gets and doesn't get ... larger versions taken from modified thumbnail links in their GOG Library.
      Downloads Dropbox  (see the GOG example in Post #7)
      ADDENDUM
      In reality, compared to most stores I have come across, the GOG store is great, well setup and laid out. and for most things, including their Wishlist, is more than adequate. So I rarely do a full list Price Query ... so much quicker and easier to just check the two pages of my in-store wishlist. When I first started work on IonGoG Wishlist, the in-store wishlist wasn't as good as it is now.
      All that said, I still find it handy to use IonGoG Wishlist, for a variety of things - Offline browsing, Cover images to use with my bought & downloaded game folders, price changes history (and patterns of GOG behavior for sales etc), a bought list (with price I paid and date etc), Game Notes & Warnings, etc. And while not as quick as just checking the pages of your in-store wishlist, you can just set the full, favorites or non-favorites Query going, while you go away and do something else, and then later come back and look at the highlighted changes that may have occurred.
    • Mannyfresh31
      By Mannyfresh31
      This is a game that I'm developing for Slot machines I just finished translating it to English my original version is in Spanish so if I miss spelled or translated something wrongly please accept my apologies I just releasing the Compile version this time just the .exe file Because I'm saving the code for myself since the software was originally written for my business or if someone wants it they have to pay but not you you getting it for free here at Autoit .
      once you run the software for first time is going to ask you for a license and it wont work without it you can get an Access code (license) by request just PM me and provide the code that the software will give when you press the cancel button three times.
      anyways once you're in the game the following hotkeys are set for interacting with it
      "q" for slot one or one credit
      "d" for slot two or five credits
      "1" or "2" or "3" or "4" or "5" to play simple, double, threeple, etc.  once you have credits of course
      "p" to stop the numbers once you're playing
      "c" for configurations or settings
      "i" for printing the receipt
      "s" for exit
      "t" for trading points for credits
       
      Link to download the game https://drive.google.com/open?id=1x22AM80fjrDjTwwAp_TqbdWyTabawoQX
       
      and here are some videos so you can see what the game is about
       
       
       
       
       
       
       
       
    • francoiste
      By francoiste
      this is a follow-up to
      i sporadically and very rarely get an access violation exception.
      here is some simplyfied repro code:
      #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Change2CUI=y #AutoIt3Wrapper_Run_Tidy=y #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include-once #include <Array.au3> #include <security.au3> ;~ #include "ESC_Globals.au3" Global Const $WTS_CURRENT_SESSION = -1 Global Const $WTS_CURRENT_SERVER_HANDLE = 0 Global Const $WTS_CLIENTPROTOCOLTYPE = 16 Global Const $WTS_CONNECTSTATE = 8 Global Const $WTS_USERNAME = 5 Global Const $tagWTS_SESSION_INFO = _ "dword SessionId;" & _ "ptr WinStationName;" & _ "uint State" Global Const $tagWTS_PROCESS_INFO = _ "DWORD SessionId;" & _ "DWORD ProcessId;" & _ "PTR pProcessName;" & _ "PTR pUserSid" For $i = 0 To 1000 * 20 ConsoleWrite("iteration " & $i & @CRLF) _GetProcessList() Sleep(1000) Next MsgBox(0, "COMPLETED", "everything done") ;***************************************** ;# returns an array: ProcessName | ProcessID | SessionID | ProcessOwner Func _GetProcessList() Local $i, $aRet ConsoleWrite("_GetProcessList() --> " & @AutoItPID & @CRLF) Local $aProcessList = ProcessList() $aRet = DllCall("WTSApi32.dll", "int", "WTSEnumerateProcesses", "int", $WTS_CURRENT_SERVER_HANDLE, "int", 0, "int", 1, "ptr*", 0, "int*", 0) If @error Or ($aRet[0] == 0) Then MsgBox(4096 + 48, "Error", "Failed invoking WTSEnumerateProcesses") Return (SetError(1, 0, -1)) EndIf Local $array[$aRet[5]][4] Local $mem = DllStructCreate($tagWTS_PROCESS_INFO, $aRet[4]) For $i = 0 To $aRet[5] - 1 ConsoleWrite("IT: " & $i) ;# DEBUG $mem = DllStructCreate($tagWTS_PROCESS_INFO, $aRet[4] + ($i * DllStructGetSize($mem))) ConsoleWrite(" - PID: ") ;# DEBUG $array[$i][1] = Int(DllStructGetData($mem, "ProcessId"), 1) ;# convert to Int32 ConsoleWrite($array[$i][1]) ;# DEBUG ConsoleWrite("; SID: ") ;# DEBUG $array[$i][2] = Int(DllStructGetData($mem, "SessionId"), 1) ;# convert to Int32 ConsoleWrite($array[$i][2]) ;# DEBUG Local $name1 = "???" For $j = 1 To $aProcessList[0][0] If $aProcessList[$j][1] == $array[$i][1] Then $name1 = $aProcessList[$j][0] ExitLoop EndIf Next ConsoleWrite("; NAME1: " & $name1) ;# DEBUG ConsoleWrite("; NAM") ;# DEBUG Local $ret2 = DllStructGetData($mem, "pProcessName") ConsoleWrite("E") ;# DEBUG Local $ret3 = DllStructCreate("char[256]", $ret2) Local $myRet = @error ConsoleWrite(": ") ;# DEBUG If $myRet == 0 Then Local $string = "" & DllStructGetData($ret3, 1) & "" ;# <==== here it sometimes CRASHES $array[$i][0] = $string ConsoleWrite($array[$i][0]) ;# DEBUG Else MsgBox(4096 + 48, "Error", "Failed for DllStructCreate: " & $myRet) ;# i never got here $array[$i][0] = "???" ConsoleWrite($array[$i][0]) ;# DEBUG EndIf ConsoleWrite("; OWNER") ;# DEBUG Local $ret3 = _Security__LookupAccountSid(DllStructGetData($mem, "pUserSid")) ConsoleWrite(": ") ;# DEBUG If IsArray($ret3) Then $array[$i][3] = "" & $ret3[1] & "/" & $ret3[0] & "" ConsoleWrite($array[$i][3]) ;# DEBUG EndIf ConsoleWrite(@CRLF) ;# DEBUG Next ConsoleWrite("endLoop." & @CRLF) ;# DEBUG DllCall("WTSApi32.dll", "int", "WTSFreeMemory", "int", $aRet[4]) ConsoleWrite("_GetProcessList() <-- " & @AutoItPID & @CRLF) ;# DEBUG Return $array EndFunc ;==>_GetProcessList
      first of all i'd like to understand WHY it crashes in DllStructGetData.
      and then i'd like to AVOID it, of course
      so far i have found no way to add some try-catch logic in AutoIt.
      any ideas why it would crash under very rare circumstances?
       
      my script is 32bit executed on windows 64bit OS.
      i have seen it on both, windows 7 and windows 10.
      i have seen it with both, script execution and compiled exe.
    • Shedunn
      By Shedunn
      I recently installed AutoIT(the most recent version) on my work computer and everytime I try to use Koda to generate code for a GUI Koda freezes....nothing can be clicked on and I have to use task manager to end the task.  It doesn't seem to matter if I open a file or if I try with a fresh design.  It also freezes if I try to change any settings within Koda

      I've tried uninstalling everything AutoIT related and reinstalling and restarting the computer.  No matter what it still does it
       
      Is there a setting somewhere that could be causing this?
×