VAN0 Posted March 30 Share Posted March 30 (edited) I'm in a process of optimizing my script to converts message boxes into notification-like popup. My last challenge is to bring down CPU usage to 0 while detecting click/key press in external application to hide my popup without interrupting. Currently I'm using this in a loop: For $i = 0 To 255 If (_IsPressed(Hex($i), $hUser32_Dll)) Then closePopup() ExitLoop EndIf Next It works fine, however it uses 3% CPU I know I could use _WinAPI_UnhookWindowsHookEx for $WH_KEYBOARD and $WH_MOUSE events, which I've tested, and it works wonderfully. But perhaps there is a better method available? Thank you. Edited March 30 by VAN0 Link to comment Share on other sites More sharing options...
spudw2k Posted April 4 Share Posted April 4 (edited) Is the goal to suppress your popup if the user does any activity, or specific key presses or mouse clicks? One idea that comes to mind is just check idle time. _WinAPI_GetIdleTime() Edited April 4 by spudw2k Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX Builder Misc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retrieve SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose Array Projects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalc Cool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
VAN0 Posted April 4 Author Share Posted April 4 My idea was to show a popup, and hide it after 10 sec, however if user continue working with that program, like pressed any key, or clicked, then hide the popup so it doesn't interfere. _WinAPI_GetIdleTime() wouldn't work, because it's triggered by mouse move, also, I'm trying to avoid using the loop, as it seems to be the most inefficient. So far, I'm achieving 0% CPU usage by registering $WH_KEYBOARD and $WH_MOUSE event listener while popup is opened and deregistering it when it's closed. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now