potatos_x86 Posted March 3, 2017 Share Posted March 3, 2017 Hi guys and gals, I do IT support for a school, and they recently bought a no-name Chinese laser engraver for one of their classes. This thing has really basic software and hardly any documentation. My problem is that I want to create a script that alerts me (or a teacher) when it is done running a job, but it has no API or web interface or anything like that. I hate this machine, but it's my job to support it :/ I know the amount of Gcode steps that are required for a given job, so I was able to find the memory address in CheatEngine. I am attempting to read it with Nomadmemory.au3. The value required is a Double, which apparently AutoIt does not play nicely with. I researched this for a few hours and didn't have any luck. I've run the variable against command like IsArray, IsBinary, IsNumber, etc. The value is: - A double, 8 bytes - Is not a fraction - Not an array - Not a binary - Is a number - Is not hex - Is not a string So basically, I'm stumped as to how to read this value and turn it into a variable that my script can work with. I just need to logically compare it to my known amount of steps (173, in my case) and act based on that. I've tried converting the double value using Number, Int, Dec, Hex, etc., and calling the Double flag where applicable. No luck - it always shows $steps as a 0. My (very rough) code: #RequireAdmin #AutoIt3Wrapper_UseX64=n #include <NomadMemory.au3> #include <WindowsConstants.au3> #include <MsgBoxConstants.au3> #include <String.au3> SetPrivilege("SeDebugPrivilege", 1) $dAddress = 0x0A65A4D8 ;;gcode steps count $MemOpen = _MemoryOpen(ProcessExists("cdscutter_x86.exe")) While 1 $steps = Number((_MemoryRead($dAddress, $MemOpen)),2) ToolTip($steps,0,0) call("alert") Sleep(200) WEnd If $steps >= 173 then call("alert") EndIf Func alert () ;;placeholder - email or Prowl alert;; EndFunc Link to comment Share on other sites More sharing options...
potatos_x86 Posted March 3, 2017 Author Share Posted March 3, 2017 Can't edit my original post? Also meant to say that I can successfully read values from this program when they are 4-byte integers, but doubles don't work at all. Link to comment Share on other sites More sharing options...
RTFC Posted March 3, 2017 Share Posted March 3, 2017 @potatos_x86: Welcome to the forums. I would suggest you load the value into a struct (check out DllstructCreate and related commands in the Help), and then read the value from the struct. I can assure you that AutoIt most definitely supports doubles; I use them all the time. My Contributions and Wrappers Spoiler BitMaskSudokuSolver BuildPartitionTable CodeCrypter CodeScanner DigitalDisplay Eigen4AutoIt FAT Suite HighMem MetaCodeFileLibrary OSgrid Pool RdRand SecondDesktop SimulatedAnnealing Xbase I/O Link to comment Share on other sites More sharing options...
potatos_x86 Posted March 4, 2017 Author Share Posted March 4, 2017 Ok, I've pasted this together with guidance from the DllStructCreate remarks, but it only passes zeroes. Do you guys know what I'm doing wrong? Not sure if I need to specify that it's byte data, or specify that its source is a double. Deeply confused and would appreciate any input. Local Const $tagSTRUCT1 = "struct;byte var1;byte var2;byte var3;byte var4[128];endstruct" DllStructSetData($tSTRUCT1, "var4", ((_MemoryRead($dAddress, $MemOpen)))) MsgBox($MB_SYSTEMMODAL, "", "Struct Size: " & DllStructGetSize($tSTRUCT1) & @CRLF & _ "Struct pointer: " & DllStructGetPtr($tSTRUCT1) & @CRLF & _ "Data:" & @CRLF & _ DllStructGetData($tSTRUCT1, 1) & @CRLF & _ ; Or "var1" instead of 1. DllStructGetData($tSTRUCT1, "var2") & @CRLF & _ ; Or 2 instead of "var2". DllStructGetData($tSTRUCT1, 3) & @CRLF & _ ; Or "var3" instead of 3. DllStructGetData($tSTRUCT1, 4)) ; Or "var4" instead of 4. Link to comment Share on other sites More sharing options...
jchd Posted March 4, 2017 Share Posted March 4, 2017 Your code doesn't create the structure. Provided the address is correct, what does this give? Local $dAddress = 0x0A65A4D8 ;;gcode steps count address (example) Local $tNbSteps = DllStructCreate("double", $dAddress) DllStructSetData($tNbSteps, 1, (_MemoryRead($dAddress, $MemOpen))) MsgBox($MB_SYSTEMMODAL, "", "Struct Size: " & DllStructGetSize($tNbSteps) & @CRLF & _ "Struct pointer: " & DllStructGetPtr($tNbSteps) & @CRLF & _ "Data:" & @CRLF & DllStructGetData($tNbSteps, 1)) This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
toto22 Posted January 27, 2018 Share Posted January 27, 2018 Good Day, I know its an old thread. However, I have same issue. My script keep on crashing. I'm trying to get a "double" value from memory Opt("WinTitleMatchMode", 4) Global $ProcessID = WinGetProcess("TI Pro") If $ProcessID = -1 Then MsgBox(4096, "ERROR", "Failed to detect process.") Exit EndIf Local $DllInformation = _MemoryOpen($ProcessID) If @Error Then MsgBox(4096, "ERROR", "Failed to open memory.") Exit EndIf Local $dAddress = 0x1FECD474 Local $tNbSteps = DllStructCreate("double", $dAddress) Local $value = DllStructSetData($tNbSteps, 1, (_MemoryRead($dAddress, $DllInformation))) MsgBox($MB_SYSTEMMODAL, $value) Link to comment Share on other sites More sharing options...
Developers Jos Posted January 27, 2018 Developers Share Posted January 27, 2018 Define crashing? What exactly are you trying here? Jos toto22 1 SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
toto22 Posted January 27, 2018 Share Posted January 27, 2018 I get error message "Auto-it Script has stopped working" my original script is this: Opt("WinTitleMatchMode", 4) Global $ProcessID = WinGetProcess("TI Pro") If $ProcessID = -1 Then MsgBox(4096, "ERROR", "Failed to detect process.") Exit EndIf Local $DllInformation = _MemoryOpen($ProcessID) If @Error Then MsgBox(4096, "ERROR", "Failed to open memory.") Exit EndIf $Value = Number(_MemoryRead(0x1FECD474, $DllInformation),2) If @Error Then MsgBox(4096, "ERROR", "Failed to read memory.") Exit EndIf _MemoryClose($DllInformation) If @Error Then MsgBox(4096, "ERROR", "Failed to close memory.") Exit EndIf It returns 4 Bit value. However, I need Double type value. 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