Jump to content

Search the Community

Showing results for tags 'sensor'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • General
    • Announcements and Site News
    • Administration
  • AutoIt v3
    • AutoIt Help and Support
    • AutoIt Technical Discussion
    • AutoIt Example Scripts
  • Scripting and Development
    • Developer General Discussion
    • Language Specific Discussion
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office


  • AutoIt Team
    • Beta
    • MVP
  • AutoIt
    • Automation
    • Databases and web connections
    • Data compression
    • Encryption and hash
    • Games
    • GUI Additions
    • Hardware
    • Information gathering
    • Internet protocol suite
    • Maths
    • Media
    • PDF
    • Security
    • Social Media and other Website API
    • Windows
  • Scripting and Development
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Find results in...

Find results that contain...

Date Created

  • Start


Last Updated

  • Start


Filter by number of...


  • Start



Member Title




Found 3 results

  1. Below is a function w/ a working example showing how to access the AIDA64 shared memory. First enable shared memory here: Preferences > Hardware Monitoring > External Applications > Enable Shared Memory The length of the data depends on the number of active sensors and their content. As AIDA64 does not provide a buffer size value, we use _WinAPI_GetSystemInfo() <WinAPISys.au3> to get dwPageSize ($aArray[1]). This value is the used as an address offset, and we continue reading chunks of data until we encounter a 0x00 NUL character. Based on the Delphi example found in the AIDA64 documentation: https://www.aida64.co.uk/user-manual/external-applications Feedback appreciated, especially as all this shared memory stuff is not my ordinary cup of... cake. And regarding this whole ordeal of reading data without knowing the exact length; I'm suspecting my solution to read chunks of data like done below is not by the book, and I'm concerned what might happen if the final chunk is exactly 4096 bytes in length. Will there still be a NUL terminator there? Hmm. #NoTrayIcon #include <WinAPIFiles.au3> #include <WinAPISys.au3> ; #INDEX# =========================================================================================================================== ; Title .........: AIDA64 Shared Memory access for AutoIt3 ; Author(s) .....: demux4555 ; Reference .....: https://www.aida64.co.uk/user-manual/external-applications ; =================================================================================================================================== Global $vSharedmem_data ; The variable used to store the data we read from the shared memory Global $return = ExtApp_SharedMem_ReadBuffer_v2($vSharedmem_data) ; Now, let's see what happens when we run the function... If @error Then _Echo("! ExtApp_SharedMem_ReadBuffer_v2(): @errror = " & @error) If IsBinary($vSharedmem_data) Then ; Convert type Binary to actual human readable text. We also remove the excess of trailing 0x00 characters. $vSharedmem_data = StringStripWS(BinaryToString($vSharedmem_data), $STR_STRIPLEADING+$STR_STRIPTRAILING) EndIf _Echo() _Echo("> return = " & $return) ; The return value. Will be True if everything went ok. _Echo("> length = " & StringLen($vSharedmem_data)) ; The number of characters read from shared memory. _Echo("> data = " & $vSharedmem_data) ; The actual data. _Echo("> data(40) = " & "..." & StringRight($vSharedmem_data, 40)) ; shows the 40 right-most characters, and _should_ show the very end of the data at this point. _Echo() Exit ; #FUNCTION# ==================================================================================================================== ; Name ..........: ExtApp_SharedMem_ReadBuffer_v2 ; Description ...: AIDA64 Shared Memory Example for AutoIt3 ; Syntax ........: ExtApp_SharedMem_ReadBuffer_v2(Byref $_dOutput[, $_sSharedmemName = "AIDA64_SensorValues"]) ; Parameters ....: $_dOutput - [in/out] Variable to store the read data. ; $_sSharedmemName - [optional] Name of the AIDA64 shared memory. Default is "AIDA64_SensorValues". ; Return values .: Success: True. $_dOutput will be type Binary, containing a string of the XML values of the active sensors. ; Failure: False. ; Author ........: demux4555 ; Reference .....: https://www.aida64.co.uk/user-manual/external-applications ; =============================================================================================================================== Func ExtApp_SharedMem_ReadBuffer_v2(ByRef $_dOutput, $_sSharedmemName = "AIDA64_SensorValues") Local $_bReturn = False Local $_aGSI = _WinAPI_GetSystemInfo() ; Retrieves information about the current system... Ref: https://docs.microsoft.com/en-us/windows/win32/api/sysinfoapi/nf-sysinfoapi-getsysteminfo Local $_iPageSize = $_aGSI[1] ; ... the page size and the granularity of page protection and commitment. Usually it is 4096, but we read it anyway. Ref: https://docs.microsoft.com/en-us/windows/win32/api/sysinfoapi/ns-sysinfoapi-system_info Local $_hMapping = _WinAPI_OpenFileMapping($_sSharedmemName, $FILE_MAP_READ) ; Opens a named file mapping object. Ref: https://docs.microsoft.com/en-us/windows/win32/api/memoryapi/nf-memoryapi-openfilemappingw If Not IsPtr($_hMapping) Then Return SetError(-2, 0, $_bReturn) Local $_pMappedData = _WinAPI_MapViewOfFile($_hMapping, 0, 0, $FILE_MAP_READ) ; Pointer to the start address. Maps a view of a file mapping into the address space of a calling process. Ref: https://docs.microsoft.com/en-us/windows/win32/api/memoryapi/nf-memoryapi-mapviewoffile If @error Or Not IsPtr($_pMappedData) Then Return SetError(-2, 0, $_bReturn) ; Now we loop until we reach the end of the data. Local $_tData, $_dBuffer While 1 $_tData = DllStructCreate("BYTE[" & $_iPageSize & "]", $_pMappedData) ; Note: we use type BYTE[] (AutoIt type Binary) instead of CHAR[] (AutoIt type String). This allows us to look for value 0x00 (NUL termination of the data). If @error Then ExitLoop $_dBuffer = DllStructGetData($_tData, 1) ; The returned value is type Binary. If @error Or ($_dBuffer==0) Or (BinaryLen($_dBuffer)=0) Then ExitLoop ; Pretty sure $_dBuffer==0 can not happen, so just in case. $_dOutput = Binary($_dOutput & $_dBuffer) ; Add the read data to the end of the output variable. If StringRight($_dBuffer, 2)=="00" Then ExitLoop ; Look for NUL termination of the string data. $_pMappedData += $_iPageSize ; We change the address by using the page granularity value (i.e. 4096) as the offset. WEnd ; Quick cleanup $_bReturn = _WinAPI_UnmapViewOfFile($_pMappedData)=1 ; Unmaps a mapped view of a file from the calling process's address space. Ref: https://docs.microsoft.com/en-us/windows/win32/api/memoryapi/nf-memoryapi-unmapviewoffile _WinAPI_CloseHandle($_hMapping) Return $_bReturn EndFunc; Func _Echo($_data = "") ConsoleWrite($_data & @CRLF) EndFunc
  2. Is there any way to send variables/values to a script via parameters during runtime? My current setup is to have a main script that always runs. This script basically sits in the background. After 1 minute, it reads text files (made via a second script), parses out the values, averages them per sensor, and posts to Thingpseak. The secondary script does not permanently run but instead runs via Eventghost when Eventghost gets GET requests from the sensors. I am looking to see if there is a way I could just have Eventghost send the parameter straight to the primary script while it is running, thus removing the need to write to files/have multiple scripts. EDIT: I just realized I could have Autoit process GET requests to do this. Doh. Point still stands though, is there a way to send values to a running script without inputboxes or reading from files?
  3. Halo wounderfull Autoit Forum I have gotten a new laptop that i am going to have the next few year and i would like to be able to get data from all its sensors like Location & Movement (GPS, Accelometer) I have gotten the GPS to work I have found the code for the Accelorometer but its in C++ (and i have no experiance with .dll calls and c++) Could some on PLEASE help me / point me in the right direction ass i just cant get it to work in autoit / know where to start here is the autoit code i have tried so far but keep getting @error 1 = unable to use the DLL file, ;/* * LoadSensorDLL.cpp * * Created on: Feb 11, 2012 * Author: CONG NGUYEN * */ #include <iostream> #include <windows.h> #include <stdio.h> #include <math.h> struct AccelData { int status; short x; //raw data short y; //raw data short xx; //avg. of 40ms short yy; //avg. of 40ms char temp; //raw value short x0; //used for auto-center short y0; //used for auto-center }; using namespace std; typedef void * (__stdcall *ShockproofGetAccelerometerData)(AccelData* accData); //function prototypes void calibrate(void); void calibrateX(); void calibrateY(); short getAccelX(); short getAccelY(); double getRotationRadiansX(); double getRotationDegreesX(); double getRotationRadiansY(); double getRotationDegreesY(); //declare constants const double PI = 3.141592; //declare global variables HINSTANCE hinstDLL; AccelData accData = {0,0,0,0,0,0,0,0}; ShockproofGetAccelerometerData pfnGetData; bool isSupported; //declare global variables used for calibration and movement short x_hor = 0; short y_hor = 0; short x_max = 0; short y_max = 0; double x_norm = 0.0; double y_norm = 0.0; double test = 0.0; int main(void) { int loop = 1; hinstDLL = LoadLibrary(L"Sensor.dll"); if(hinstDLL == 0) { hinstDLL = LoadLibrary(L"sensor.dll"); } if(hinstDLL == 0) { isSupported = false; } else { isSupported = true; pfnGetData = (ShockproofGetAccelerometerData) GetProcAddress((HINSTANCE) hinstDLL, "ShockproofGetAccelerometerData"); } calibrate(); calibrateX(); calibrateY(); cout << x_hor << ", " << y_hor << endl; cout << x_max << ", " << y_max << endl; cout << endl; cout << "Calibration completed.\n"; getchar(); cout << "TIlt 45 degrees. Press any keys to confirm.\n"; getchar(); cout << getRotationDegreesY(); //end program getchar(); FreeLibrary(hinstDLL); return 0; } short getAccelX() { pfnGetData(&accData); return accData.x; } short getAccelY() { pfnGetData(&accData); return accData.y; } void calibrate(void) { cout << "Lay Thinkpad onto a flat and horizontal ground.\n"; cout << "Press any key to continue.\n"; if(getchar() == '\n') { x_hor = getAccelX(); y_hor = getAccelY(); } } void calibrateX() { cout << "Pitch your Thinkpad a bit backwards.\n"; cout << "Press any key, then rotate your Thinkpad back to normal position.\n"; getchar(); while(getAccelX() != x_hor) { if(getAccelX() > x_max) { x_max = getAccelX(); } } } void calibrateY() { cout << "Roll your Thinkpad to the right a bit.\n"; cout << "Press any key, then rotate your Thinkpad back to normal position.\n"; getchar(); while(getAccelY() != y_hor) { if(getAccelY() > y_max) { y_max = getAccelY(); } } } double getRotationRadiansX() { x_norm = (double)((double)getAccelX() - (double)x_hor) /((double)x_max - (double)x_hor); if(x_norm > 1) { x_norm = 1/x_norm; } return acos(x_norm); } double getRotationDegreesX() { return getRotationRadiansX() * 180 / PI; } double getRotationRadiansY() { y_norm = (double)((double)getAccelY() - (double)y_hor) /((double)y_max - (double)y_hor); if(y_norm > 1) { y_norm = 1/y_norm; } return acos(y_norm); } double getRotationDegreesY() { return getRotationRadiansY() * 180 / PI; } #cs ---------------------------------------------------------------------------- Author: Me Script Function: Get Data from the Different Sensors in the Computer 1. Accelerometer / Gyroscope 2. GPS / Location 3. ? 4. ? ----------SysWOW64---------------- Sensor.dll SensorsApi.dll SensorCpl.dll ----------------------------------- ----------System32--------------- Sensor64.dll SensorsApi.dll SensorsClassExtension.dll SensorCpl.dll ---------------------------------- ================================== How To / Help / Code Convert ========================= http://flashandrc.wordpress.com/2012/02/12/pulling-data-from-thinkpad-aps-sensor-using-c/ ; C++ http://www.xtremevbtalk.com/showthread.php?t=284179 ; Vbs http://www.autoitscript.com/forum/topic/71001-problems-with-dllcall/?hl=sensor#entry519806 ; Autoit3 ========================================================================================= ================================== Credits (UDF/Code Lines/Code Samples) ================ Autoit3 Forum and all its Users whom i have borrowed a line of code or sample script Thanks to all that have helped as well ========================================================================================= #ce ---------------------------------------------------------------------------- #include <Array.au3> #include <WinApi.au3> #region === Global Variables === Global $SensorWOW #endregion ===================== #region ============================================= SysWOW64 Dll ================================================================ $SensorWOW = DllOpen(@WindowsDir&"\SysWOW64\Sensor.dll") If $SensorWOW = -1 Then MsgBox(16,"Error","Dll File didn't open") #cs ============================================= Functions in Sensor64.dll =================================================== ShockproofCallSMAPIBIOS 0x000000018000230c 0x0000230c 1 (0x1) Sensor64.DLL C:\Windows\System32\Sensor64.DLL Exported Function ShockproofControl 0x0000000180001750 0x00001750 2 (0x2) Sensor64.DLL C:\Windows\System32\Sensor64.DLL Exported Function ShockproofEnableDisableSnooze 0x0000000180002230 0x00002230 3 (0x3) Sensor64.DLL C:\Windows\System32\Sensor64.DLL Exported Function ShockproofGetAccelerometerData 0x0000000180001da4 0x00001da4 4 (0x4) Sensor64.DLL C:\Windows\System32\Sensor64.DLL Exported Function ShockproofGetAccelerometerDataEx 0x0000000180001e78 0x00001e78 5 (0x5) Sensor64.DLL C:\Windows\System32\Sensor64.DLL Exported Function ShockproofGetAccelerometerMutex 0x0000000180001c78 0x00001c78 6 (0x6) Sensor64.DLL C:\Windows\System32\Sensor64.DLL Exported Function ShockproofGetAutoDisable 0x00000001800016c0 0x000016c0 7 (0x7) Sensor64.DLL C:\Windows\System32\Sensor64.DLL Exported Function ShockproofGetPenAbility 0x00000001800025e8 0x000025e8 8 (0x8) Sensor64.DLL C:\Windows\System32\Sensor64.DLL Exported Function ShockproofGetPenDelayTime 0x00000001800023e4 0x000023e4 9 (0x9) Sensor64.DLL C:\Windows\System32\Sensor64.DLL Exported Function ShockproofGetPenFeature 0x00000001800024e0 0x000024e0 10 (0xa) Sensor64.DLL C:\Windows\System32\Sensor64.DLL Exported Function ShockproofGetShockStatus 0x0000000180001b4c 0x00001b4c 11 (0xb) Sensor64.DLL C:\Windows\System32\Sensor64.DLL Exported Function ShockproofGetSlaveCPUinfo 0x0000000180001be4 0x00001be4 12 (0xc) Sensor64.DLL C:\Windows\System32\Sensor64.DLL Exported Function ShockproofGetUnloadCnt 0x0000000180001abc 0x00001abc 13 (0xd) Sensor64.DLL C:\Windows\System32\Sensor64.DLL Exported Function ShockproofGetVersion 0x0000000180001800 0x00001800 14 (0xe) Sensor64.DLL C:\Windows\System32\Sensor64.DLL Exported Function ShockproofInformPMevent 0x0000000180001f4c 0x00001f4c 15 (0xf) Sensor64.DLL C:\Windows\System32\Sensor64.DLL Exported Function ShockproofInvokeSnooze 0x00000001800020c8 0x000020c8 16 (0x10) Sensor64.DLL C:\Windows\System32\Sensor64.DLL Exported Function ShockproofManualSensitivitySetting 0x0000000180001fc8 0x00001fc8 17 (0x11) Sensor64.DLL C:\Windows\System32\Sensor64.DLL Exported Function ShockproofReleaseAccelerometerMutex 0x0000000180001d24 0x00001d24 18 (0x12) Sensor64.DLL C:\Windows\System32\Sensor64.DLL Exported Function ShockproofSetAutoDisable 0x0000000180001640 0x00001640 19 (0x13) Sensor64.DLL C:\Windows\System32\Sensor64.DLL Exported Function ShockproofSetPenDelayTime 0x0000000180002470 0x00002470 20 (0x14) Sensor64.DLL C:\Windows\System32\Sensor64.DLL Exported Function ShockproofSetPenFeature 0x0000000180002574 0x00002574 21 (0x15) Sensor64.DLL C:\Windows\System32\Sensor64.DLL Exported Function ShockproofSnoozeSetting 0x0000000180002130 0x00002130 22 (0x16) Sensor64.DLL C:\Windows\System32\Sensor64.DLL Exported Function ShockproofTaskComplete 0x0000000180001fbc 0x00001fbc 23 (0x17) Sensor64.DLL C:\Windows\System32\Sensor64.DLL Exported Function #ce ======================================================================================================================== ;~ $SensorsApiWOW = DllOpen(@WindowsDir&"\SysWOW64\SensorsApi.dll") #cs ============================================= Functions in SensorsApi.dll ================================================= ;~ DllCanUnloadNow 0x07658f96 0x00008f96 1 (0x1) SensorsApi.dll C:\Windows\SysWOW64\SensorsApi.dll Exported Function ;~ DllGetClassObject 0x07659bbd 0x00009bbd 2 (0x2) SensorsApi.dll C:\Windows\SysWOW64\SensorsApi.dll Exported Function ;~ DllRegisterServer 0x07659ddb 0x00009ddb 3 (0x3) SensorsApi.dll C:\Windows\SysWOW64\SensorsApi.dll Exported Function ;~ DllUnregisterServer 0x07659ea6 0x00009ea6 4 (0x4) SensorsApi.dll C:\Windows\SysWOW64\SensorsApi.dll Exported Function ;~ SensorPermissionsHandler 0x07666a4c 0x00016a4c 5 (0x5) SensorsApi.dll C:\Windows\SysWOW64\SensorsApi.dll Exported Function ;~ SensorPermissionsHandlerA 0x07666a4c 0x00016a4c 6 (0x6) SensorsApi.dll C:\Windows\SysWOW64\SensorsApi.dll Exported Function ;~ SensorPermissionsHandlerW 0x0766681c 0x0001681c 7 (0x7) SensorsApi.dll C:\Windows\SysWOW64\SensorsApi.dll Exported Function #ce ======================================================================================================================== #endregion ======================================================================================================================== $AccData = DllStructCreate("int;short;short;short;char;short;short") ;~ $res = DllCall("sensor.dll","none","ptr",DllStructGetPtr($AccData)) ;~ For $i=1 To 23 ;~ $status = DllStructGetData($AccData,$i) ;~ ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $status = ' & $status & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console ;~ Next $adll = DllCall($SensorWOW, "none", "ShockproofGetAccelerometerData", $AccData,"handle") If Not @error Then MsgBox(0, "Return", $adll[1] & " " & $adll[1] & " Length " & StringLen($adll[1])) Else MsgBox(0, "Error", @error) EndIf Thanks in advanced Sensor.7z
  • Create New...