Jump to content

[Solved] Pass Varaibles Into Script


 Share

Recommended Posts

If ProcessExists('Media.exe') Then

    ProcessClose('Media.exe')

    _F12()

Endif

Media.Exe

#NoTrayIcon

Sleep(1000)

So if Media.exe runs, the main-script detects it and acts according.

Is there any more proffesional way for me to Pass a varaible into the main-script ?

Edited by IanN1990
Link to comment
Share on other sites

If ProcessExists('Media.exe') Then

ProcessClose('Media.exe')

_F12()

Endif

Media.Exe

#NoTrayIcon

Sleep(1000)

So if Media.exe runs, the main-script detects it and acts according.

Is there any more proffesional way for me to Pass a varaible into the main-script ?

Clarify, I don't see you passing anything to anything else here.

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

If you need to send your script information when you run it, look at command line parameters in the Help file.

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

  • Moderators

Hi, IanN1990. Not sure what you mean about "any more professional way" exactly. Are you trying to search for, and close, the process any time you detect it throughout your script? If so, maybe an AdLibRegister would better suit your needs. You can then check for it without the Sleep call.

AdLibRegister("_media")
Func _media()
   If ProcessExists("Media.exe") Then
      ProcessClose("Media.exe")
   EndIf
EndFunc

Edit: From the three replies you can see we're thoroughly confused as to just what you're trying to accomplish, and would love some clarification :)

Edited by JLogan3o13

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

Hm ok here would be a better example :)

I have a logitech Keybaord with some Unique buttons that cant be bound to Hotkey or IsPressed, so instead i make that button run the "Media.exe" which is a blank exe which is detected by my Main Script which runs 24/7

So what i was looking for is a way to make the Media.exe run which some-how passes information or varaibles into the main-script instead of having the main-script detect it ;)

Link to comment
Share on other sites

IanN1990,

Firstly check this link to see can you find the unique button you are talking about.

http://msdn.microsoft.com/en-us/library/ms927178.aspx

then i believe every buttons ( even buttons that are provided by some keyboards ) has a unique value, for example the value for Enter is 0x0D, if you find the hex value of your desired button you can assign a hotkey to it using _IsPressed().

Link to comment
Share on other sites

You could have window in your main script and a button, perhaps an input box too.

When Media.exe starts, it should look for the window, enter the variables into the input box, and click the button.

WinExists, WinGetHandle, Controlsend, ControlClick are your friends if you do it like that.

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

hmm there seams to be some confussion. So here is another example.

When my computer locks (windows screen) and logs in from that screen. The Task Secdular runs a .exe i made called Login.exe. Which has no code apart from #Notray and sleep(1000). So the exe appears in the task-manger for about a second.

My main script which runs 24/7 would detect this login.exe script, close it and then the main-script knows "i have logged in" and sets my status for msn/steam/skype to online.

So my question was, is there a easier way of passing varaibles into a script.

Ie setting a variable from $a = o to $a = 1

or making it run a function

Edit As i found out processchecking is a very wasteful "cpu terms" way of doing things, i made some Hotkeys instead and made the "blank.exes" send a like Alt+Shift+F11 which wouldn't affect any application or do anything but the mainscript hotkey would pick it up and run the function

Edited by IanN1990
Link to comment
Share on other sites

as john sed, you can make your triger script do something:

1. modify something in your main gui(button, input.....)

2. modify something external that your main script monitors(reg entry, a file....)

3. UDP listen to a port with main script (in the main loop) and make triger script to UDP connect, send command, and exit

Link to comment
Share on other sites

IanN1990

You are not making any sense, what happened to Media.exe?

You bang on about this...

...

hmm there seams to be some confussion. So here is another example.

When my computer locks (windows screen) and logs in from that screen. The Task Secdular runs a .exe i made called Login.exe. Which has no code apart from #Notray and sleep(1000). So the exe appears in the task-manger for about a second.

My main script which runs 24/7 would detect this login.exe script, close it and then the main-script knows "i have logged in" and sets my status for msn/steam/skype to online.

Then you ask

"So my question was, is there a easier way of passing varaibles into a script."

They have nothing to do with each other.

From experience I know that when you are trying to con a forum full of geniuses

you ought to do your homework first.

Your steam will wait.

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

When my computer locks (windows screen) and logs in from that screen. The Task Secdular runs a .exe i made called Login.exe. Which has no code apart from #Notray and sleep(1000). So the exe appears in the task-manger for about a second.

My main script which runs 24/7 would detect this login.exe script, close it and then the main-script knows "i have logged in" and sets my status for msn/steam/skype to online.

Instead of some monitoring script running in the background looking for whether this exe is running or not, why not just have that exe that runs on login do all of the status updating? You're way over-complicating things with the monitoring script.

So my question was, is there a easier way of passing varaibles into a script.

No, your question doesn't have anything whatsoever to do with passing variables into a script. I don't see where in anything you've described where any script needs any information passed into it from some other script. You have never once stated what the variables are needed to do, what you need them to pass to whatever it is they're passing to, or how you expect these variables to be read by the whatever they've been passed to.

Explain IN DETAIL what it is you want to pass back and forth, and why they need to be passed back and forth. It seems to me that you're trying to attempt something that probably could be handled in a much simpler way than passing information to another program.

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

Ok, i will try explaining again. :)

I have my script, which when complied is called 600T. If my computer is on, this script is on. Its job is to run little tasks to make my life easier, such as hiding/showing the desktop, hiding/showing the taskbar, tri-screen dimming etc. Within this script there are varaibles/functions which can only run if a "external" (as it outside the script) event happens. So in the "Media.exe" Example. I set up my logetic keybaord so when i press "F12", it runs Media.exe. Which has the following code.

#NoTrayIcon ;As the exe is only alive for 1 second, so running this without this line = lots of dead icons in tray
sleep(1000) ;So the exe is alive for 1 second

Now my Main Script 600T would detects Media.exe has appeared in the windows Process. It would then close the process "so not to detect the same one twice" and runs the function linked with this.

Its the same for Login.exe, When ever my computer logs in it runs this blank exe. The script detects it, closes it and then sets me to online.

Now i started this thread because i found this "though it works" a very unproffesional way.

I was hoping for someone to point me in the right direction for code that would a.

Allow 1 exe to tell another exe to run function a Brew within my script I have some code like this

or

Allow 1 exe to tell another exe change $VariableA = 1

**Edit In reply within my script i have some code like this

If $Pc_lock = 0 then

My main script

else

Secruity Code to stop people getting access to my system

Endif

So when the computer locks, the $PC_Locks go to 1, so 800 lines of code that doesnt need to be run isn't run. And the secuirty code to stop people accessing my system is run. If someone attempts to gain access, and trips one of the lines it locks the system "Win+L".

So when i logg back on via the windows screen. I need a way for the script to know this is has happened. Ego the Login.exe, which the script detects and sets $PC_Lock back to 0

Edited by IanN1990
Link to comment
Share on other sites

  • Moderators
IanN1990, since you have succeeded in frustrating and confusing everyone reading this, why not just post your code? You know what they say, a script is worth 1000 words :)

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

Why not set up your background script to use a hotkey set to F12 to run whatever function that is linked to be ran when Media.exe is run instead of running another program just so you can see that F12 has been pressed?

Get rid of the monitoring for the Login.exe program completely because it's not needed. Have Login.exe do everything that the background script is doing when it sees login.exe run.

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

HotKeySet("{F12}", "_Test")
while 1
sleep(5000)
WEnd
Func _Test()
ConsoleWrite("A")
EndFunc

Assuming that code is correct, then i cant bind F12 to hotkey. As nothing happens. Which is why i have gone down this other route of instead making f12 run a autoit complied exe to tell the other exe to do something

@JLogan

You can find my code here

Edited by IanN1990
Link to comment
Share on other sites

Correct, F12 can't be bound to a hotkey. I just reread the help file regarding this idiosyncrasy with that key. You could do it with _IsPressed though.

#include <Misc.au3>
Local $hDLL = DllOpen("user32.dll")

While 1
    Sleep(5)
    If _IsPressed("7B", $hDLL) Then _Test()
WEnd
Func _Test()
    ConsoleWrite("A" & @CRLF)
    Exit
EndFunc   ;==>_Test

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

I dislike using _IsPressed unless i have no other choice because

a. it requires a slow sleep not to miss any

b. requires a higher cpu usage

c. overcatches the key

The way i done it, means every f12 click produces 1 exe, which is detected once without fail, doesn't require a low sleep and uses lower CPU.

But anyways lets put this topic to rest, i am sure i have frusated enough people

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...