Jump to content

Nomadmemory + loop with while


NandaS
 Share

Recommended Posts

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

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 Gude
How 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

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 Gude
How 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

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 by NandaS
Link to comment
Share on other sites

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 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 Gude
How 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

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 by tomaskir
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...