Durnt

Runtime adding variables to script

11 posts in this topic

#1 ·  Posted (edited)

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?

Edited by Durnt

Share this post


Link to post
Share on other sites



Search the forum for IPC (Inter-Process Communication). There exist several efficient methods to achieve what you need. Using the clipboard isn't one of them.


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 here
RegExp tutorial: enough to get started
PCRE 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)

Share this post


Link to post
Share on other sites

didn't know a good term to look for, thanks for the info

Share this post


Link to post
Share on other sites

IPC


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 here
RegExp tutorial: enough to get started
PCRE 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)

Share this post


Link to post
Share on other sites

If first Script has a GUI you could use ControlSend. But in everyc ase TCP is possible.

Share this post


Link to post
Share on other sites
4 hours ago, jchd said:

Search the forum for IPC (Inter-Process Communication). There exist several efficient methods to achieve what you need. Using the clipboard isn't one of them.

That's why I mentioned it as a tricky way.

Share this post


Link to post
Share on other sites

You mean "certain to fail miserably at any time"?


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 here
RegExp tutorial: enough to get started
PCRE 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)

Share this post


Link to post
Share on other sites
On 9/20/2016 at 5:40 PM, jchd said:

You mean "certain to fail miserably at any time"?

It can fail, only if it is interrupted by some other clipboard copy. - That is why it is tricky and even a newbie can understand it...I believe.

Share this post


Link to post
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

  • Similar Content

    • islandspapand
      Get Data from Dll / Convert C++
      By islandspapand
      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