matter Posted June 25, 2013 Share Posted June 25, 2013 (edited) Having a bit of trouble. I went over the code so many times, I thought it out while I was half asleep and wrote it on my Note 2.. Everything seems right but it is not working. from start it just freezes, and stays froze . Please help!! expandcollapse popupDIM $MousePos Dim $MousePosChange Global $processtoSuspend = "notepad.exe" While 1 $MousePos = MouseGetPos() sleep (1000) $MousePosChange = MouseGetPos () if $MousePos <> $MousePosChange then if ProcessExists ($processtoSuspend) Then _ProcessSuspend(ProcessExists ($processtoSuspend)) Else $MousePos = MouseGetPos() sleep(25000) $MousePosChange = MouseGetPos() if $MousePos <> $MousePosChange then if ProcessExists ($processtoSuspend) Then _ProcessSuspend(ProcessExists ($processtoSuspend)) Else if ProcessExists ($processtoSuspend) Then _ProcessResume(ProcessExists ($processtoSuspend)) EndIf EndIf WEnd Func _ProcessSuspend($process) $ai_Handle = DllCall("kernel32.dll", 'int', 'OpenProcess', 'int', 0x1f0fff, 'int', False, 'int', $process) $i_sucess = DllCall("ntdll.dll","int","NtSuspendProcess","int",$ai_Handle[0]) DllCall('kernel32.dll', 'ptr', 'CloseHandle', 'ptr', $ai_Handle) EndFunc Func _ProcessResume($process) $ai_Handle = DllCall("kernel32.dll", 'int', 'OpenProcess', 'int', 0x1f0fff, 'int', False, 'int', $process) $i_sucess = DllCall("ntdll.dll","int","NtResumeProcess","int",$ai_Handle[0]) DllCall('kernel32.dll', 'ptr', 'CloseHandle', 'ptr', $ai_Handle) EndFunc Edited June 25, 2013 by matter Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted June 25, 2013 Moderators Share Posted June 25, 2013 matter,Welcome to the AutoIt forum. A hint - what does MouseGetPos return? It returns an array and you cannot compare arrays directly in AutoIt - you have to compare the elements. And out of interest, why do you want to do this? M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
matter Posted June 25, 2013 Author Share Posted June 25, 2013 I work from home, I have a tripple screen setup, I am going to enable my TV as well for stats only, but do not want the stats to update while im using the PC. so i would like it to see if im not using my mouse. and if not then update stats every second. I will add msgbox with what MouseGetPos gets to see. thanks for the welcome!!! Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted June 25, 2013 Moderators Share Posted June 25, 2013 matter,MsgBox will not display anything as the function returns an array - use _ArrayDisplay. But do not forget #include Array.au3 at the top of the script. update stats every secondThat is some update rate! M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
matter Posted June 25, 2013 Author Share Posted June 25, 2013 matter, Welcome to the AutoIt forum. A hint - what does MouseGetPos return? It returns an array and you cannot compare arrays directly in AutoIt - you have to compare the elements. And out of interest, why do you want to do this? M23 ah, msgbox is blank dude >.< your awesome for pointing that out. Link to comment Share on other sites More sharing options...
matter Posted June 25, 2013 Author Share Posted June 25, 2013 matter,MsgBox will not display anything as the function returns an array - use _ArrayDisplay. But do not forget #include Array.au3 at the top of the script. That is some update rate! M23 what are you a physic? LOL Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted June 25, 2013 Moderators Share Posted June 25, 2013 matter,No, although after 5 years or so my crystal ball does help with some of the more obvious beginner problems. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Iczer Posted June 25, 2013 Share Posted June 25, 2013 Having a bit of trouble. I went over the code so many times, I thought it out while I was half asleep and wrote it on my Note 2.. Everything seems right but it is not working. from start it just freezes, and stays froze . Please help!! ... See : #include <WinAPIEx.au3> If _WinAPI_GetIdleTime() > 25000 Then Link to comment Share on other sites More sharing options...
jdelaney Posted June 25, 2013 Share Posted June 25, 2013 (edited) _timer_getidletime is probably easier, if you don't mind for mouse and keyboard presses: #include <Timers.au3> While True While _Timer_GetIdleTime() < 25000 ; looping until idle for 25 seconds Sleep(1000) WEnd ; your code to do stat updates Sleep (1000) WEnd edit: haha, 2 seconds too late ...well, same basic function, diff udf Edited June 25, 2013 by jdelaney IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. Link to comment Share on other sites More sharing options...
matter Posted June 25, 2013 Author Share Posted June 25, 2013 _timer_getidletime is probably easier, if you don't mind for mouse and keyboard presses: #include <Timers.au3> While True While _Timer_GetIdleTime() < 25000 ; looping until idle for 25 seconds Sleep(1000) WEnd ; your code to do stat updates Sleep (1000) WEnd edit: haha, 2 seconds too late ...well, same basic function, diff udf aaahh thanks dude!!!! this worked.. but paused for 50 seconds?? not sure why Link to comment Share on other sites More sharing options...
jdelaney Posted June 25, 2013 Share Posted June 25, 2013 (edited) are you sure about that ...try with this (don't move/press anything) #include <Timers.au3> While True $iTimer = TimerInit() While _Timer_GetIdleTime() < 25000 ; looping until idle for 25 seconds Sleep(1000) WEnd ; your code to do stat updates MsgBox(1,1,TimerDiff($iTimer)/1000) Sleep (1000) WEnd my message box showed very close to 25 seconds (which it will never be exact, since it takes a few seconds to start the script, and impossible to "time" the idle time...pluss the sleeps can cause the idle time to go over 25 seconds, but it should be around 25 +1 second Edited June 25, 2013 by jdelaney IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. Link to comment Share on other sites More sharing options...
matter Posted June 25, 2013 Author Share Posted June 25, 2013 are you sure about that ...try with this (don't move/press anything) #include <Timers.au3> While True $iTimer = TimerInit() While _Timer_GetIdleTime() < 25000 ; looping until idle for 25 seconds Sleep(1000) WEnd ; your code to do stat updates MsgBox(1,1,TimerDiff($iTimer)/1000) Sleep (1000) WEnd my message box showed very close to 25 seconds (which it will never be exact, since it takes a few seconds to start the script, and impossible to "time" the idle time...pluss the sleeps can cause the idle time to go over 25 seconds, but it should be around 25 +1 second ah yea im sure dude.. i tested it on local and VM and still about 50 secs.... but! ill take it!!! thanks soo much bro Link to comment Share on other sites More sharing options...
jdelaney Posted June 25, 2013 Share Posted June 25, 2013 that's so weird...put the idletime < 12500 IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. Link to comment Share on other sites More sharing options...
matter Posted June 28, 2013 Author Share Posted June 28, 2013 that's so weird...put the idletime < 12500 One last question tho. Why the $iTimer? is it doing anything? when i compile it gives me an error saying " -### Obfuscation Error: Found DllCallbackRegister() statement using unsolvable Func, which will/could lead to problems running your obfuscated script. >### current Func: _Timer_SetTimer C:Program FilesAutoIt3includeTimers.au3(275,1) Warning for line:$hCallBack = DllCallbackRegister($sTimerFunc, "none", "hwnd;int;uint_ptr;dword") Link to comment Share on other sites More sharing options...
BrewManNH Posted June 28, 2013 Share Posted June 28, 2013 Don't use any of the /strip options without using the wrapper directives to skip obfuscating certain functions that cause those warnings. Search the forum for that error and you'll find plenty of threads describing it. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator 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