NandaS Posted December 28, 2011 Share Posted December 28, 2011 Hi to everybody! I'm trying to do a loop cheking a memory state... while this memory is 0, just sleep. Something like that: Global $i = _MemoryOpen(0x005F7FEC, $Open); this memory could be only 0 or 1 while $i = 0 Sleep (100) wend and here goes the code... How can I check this memory state in a loop? I want that goes out of the loop when this memory get the state 1. Thanks Link to comment Share on other sites More sharing options...
BrewManNH Posted December 28, 2011 Share Posted December 28, 2011 Put the memory checking line inside the While loop, otherwise it's only checked once and your loop never exits. 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...
NandaS Posted December 28, 2011 Author Share Posted December 28, 2011 While $i = 0 Sleep(100) $i = _MemoryRead(0x005F7FEC, $Abrir) If $i > 0 Then ExitLoop EndIf wEnd I just imagined something like that, but it this is not exiting the loop =p Link to comment Share on other sites More sharing options...
BrewManNH Posted December 28, 2011 Share Posted December 28, 2011 There's no need for the If then checking, if $i <> 0 it's going to exit the loop. I'd guess that whatever _MemoryRead is reading, it's always returning 0. 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...
NandaS Posted December 28, 2011 Author Share Posted December 28, 2011 (edited) There is the problem... if i do that: While $i = 0 Sleep(100) $i = _MemoryRead(0x005F7FEC, $Abrir) wEnd It would read the memory every time that is looping, and when it becames different from 0 than exits the loop. But here this only exits the loop when the memory returns 1 and the program is executed twice. Crazy things happens Edited December 28, 2011 by NandaS Link to comment Share on other sites More sharing options...
BrewManNH Posted December 28, 2011 Share Posted December 28, 2011 (edited) You used _MemoryOpen in the first example script and _MemoryRead in the others, are you sure you're using the correct function? Also, I thought you wanted the loop to exit when $i was not 0. By the way, your method using the If Then statement still reads the memory every time through the loop, and will exit the loop if $i is > 0, which is almost the same as using While $i=0 except your check will only exit the loop if $i is 1 or more, not if it returns -1 or less. If the memory read only returns 1 or 0 that's not a problem, if it ever returns EDIT: Noticed that the forum software screwed with some symbols. Edited December 28, 2011 by BrewManNH 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...
Dana Posted December 28, 2011 Share Posted December 28, 2011 (edited) Why not: While 1 If ((_MemoryRead(0x005F7FEC, $Abrir) <> 0) Then ExitLoop Sleep(100) EndIf or While ((_MemoryRead(0x005F7FEC, $Abrir) = 0) Sleep(100) EndIf Unless you need $i elsewhere? Edited December 28, 2011 by Dana Link to comment Share on other sites More sharing options...
tomaskir Posted December 28, 2011 Share Posted December 28, 2011 (edited) Alright, it the 1st example you have _MemoryOpen, but in other you do not anymore. What I suggest is you read through Nomads Memory Function descriptions. What you need to do is: local $PID = ProcessExists("ProgramName_to_ReadMemoryFrom") ;get the PID local $MemoryHandle = _MemoryOpen($PID) ;open the memory while _MemoryRead(0x00123ABC, $MemoryHandle) = False ;while memory read from the location is 0 sleep(100) wend Also, the address can change everytime you run the program that you want to read from. Not sure what you are reading from, but you need a base address and an offset, or if you are reading from something more complicated you will need to read pointers. Edited December 28, 2011 by tomaskir 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