Jump to content

Task dynamic automation with ispressed


Recommended Posts

I have been experimenting with different ways to have shortcuts to load programs and do basic tasks. I have figured out the ultimate idea that I have created. Unfortunately I cannot give out the source code, as you might imagine, to prevent it being altered for negative purposes BUT.. I wanted to share "what" I did at the very least to perhaps give you some ideas.

I used the _ispressed() function to create a relatively complicated (for me any way) script program that buffers only the last 20 typed characters (limited for security reasons) in a variable. Basically I have it set at first ever run to set a pre code and a post code, meaning I will always precede a command with ;' for example and end a command with # for example. It then stores that in an ini file and allows me to set in "actions" which requires a description, command line, and load type eg if its an exe press yes else press no (run vs shellexecute). I also added a commandline detection for [script] scriptname.au3 so I can program an action to run a script. Previously to using ini files for settings I had programmed all these "actions" into the source, thus being very easy to perform non-simple exe loading etc. But since I went with ini file for settings I came up with detecting [script] xxx.ext and was able to make it set in the ini file what was needed to be pulled out and successfully run the external script, for more complicated automation etc.

I also added the following internal commands:

add - to add a new action

refresh - to reload the ini in case I manually edit it

exit - properly close the program

help - a message box with these internal commands

What can I use this for? Well for one example, if my net is going screwy I like to run a continuous ping to google to check for ping spikes etc. The problem is I have to go and load command prompt, type the command and the needed parameters to get the ping. However with this new script method all I do is type (for example) -=ping# anywhere in windows, no matter what window I have focused and it just goes and performs that, or any other, action for that "code" I typed.

What do you think to this idea? Useful? Gimmicky?

Link to comment
Share on other sites

No, because that is "a" hot"key".. My method uses codes so unless you type the whole thing eg -=dothis# it won't do anything. My method also works no matter what program I have open or what my keyboard is focused in.

Link to comment
Share on other sites

sounds neat, reminds me of launchy.

you might want to look the the _winapi_setwindowshookex function and example.

prob more stable/accurate than _ispressed.

edit:

Looks like Manadar's hotstring func uses setwindowshookex

http://autoitscript.com/forum/topic/6842...-hotkeys/page__view__findpost_

I didn't mean to discount your work. I'm just saying there are multiple ways to cook and egg.

Edited by spudw2k
Link to comment
Share on other sites

I don't see how it is different at all.

If I set a hotstring to "dotask1" then I can have a function/task run only when I type "dotask1", exactly the same as you are describing.

I see no such command in the manual.

Link to comment
Share on other sites

sounds neat, reminds me of launchy. you might want to look the the _winapi_setwindowshookex function and example. prob more stable/accurate than _ispressed. edit: Looks like Manadar's hotstring func uses setwindowshookex http://autoitscript.com/forum/topic/6842...-hotkeys/page__view__findpost_ I didn't mean to discount your work. I'm just saying there are multiple ways to cook and egg.

Indeed. I would get into other things but a) I hate using third party non-intrinsic functions that require me to back things up and keep track of what I am using, whats updated, whats broken etc and B) I don't want to get into things that are way more involved than this really, this is about my limit. Anything I have seen to do with the win api looks like letter soup to me and usually requires prior advanced knowledge of the operating system's inner workings in terms of API, which I don't.

Edited by Morthawt
Link to comment
Share on other sites

I am guessing it would be bad to release the source on here? I know there are certain types of program banned from discussion/help in this forum and although my program is not bad, technically it could relatively easily be reconfigured for negative purposes. I don't want to get suspensions or bans due to just wanting feedback on my coding style on this one.

What would you advise?

Link to comment
Share on other sites

I am guessing it would be bad to release the source on here? .....

What would you advise?

That's your discretion. As long as your code is clean of Mal-intent I don't think anyone would scold you for posting it; but don't be disappointed when you don't get the feedback you are hoping for.
Link to comment
Share on other sites

I am guessing it would be bad to release the source on here? .....

What would you advise?

That's your discretion. As long as your code is clean of Mal-intent I don't think anyone would scold you for posting it; but don't be disappointed when you don't get the feedback you are hoping for.

I see no such command in the manual.

It's not in the manual. I kindly posted a link for you since JohnOne only eluded to it.

...I hate using third party non-intrinsic functions....

Sometimes things are just complicated, it doesn't mean it's not worth looking into.
Link to comment
Share on other sites

That's your discretion. As long as your code is clean of Mal-intent I don't think anyone would scold you for posting it; but don't be disappointed when you don't get the feedback you are hoping for.

It's not in the manual. I kindly posted a link for you since JohnOne only eluded to it.

Sometimes things are just complicated, it doesn't mean it's not worth looking into.

True, but I usually like to stay within my comfort zone by trying to do things with what I have because I feel I can rely on everything that comes "with" autoit and I don't have to take any other steps other than thinking about how I am going to use it. I was not aware that someone else made something similar to the idea I had, but it feels good to me (and thats one reason I code things) that I was able to make it by myself using my own judgement and use of the tools provided.

I am not saying user defined functions that are on the forum are bad or anything, I just prefer to only use what autoit comes with because I get a better feeling about my coding that way.

I have modified my script to use the control key to preceed and end my hotkey strings to make it more universal, plus my ini file is encrypted and the internal commands like add, delete, refresh, delete, list also require the password to activate them while the actions I program into it with "add" do not require a password because nobody can see what strings I chose to load something.

Link to comment
Share on other sites

...I am not saying user defined functions that are on the forum are bad or anything, I just prefer to only use what autoit comes with because I get a better feeling about my coding that way.

I suppose you probably don't realize that _ispressed is a User Defined Function that originated on the forum before being included with the AutoIt package? Most of the UDFs included with AutoIt originated on this forum, so it was not "included" with the language.

edit: perhaps it didn't originate on the forum...not too sure...but it is a UDF none-the-less. It just went under enough scrutiny to be considered solid enough code to be included.

...my ini file is encrypted and the internal commands like add, delete, refresh, delete, list also require the password to activate them while the actions I program into it with "add" do not require a password because nobody can see what strings I chose to load something.

Interested how you implemented this. Is there any password verification? What happens if you put in a bad password? Does it recognize it and not do anything, or does it produce incorrect "commands"? Edited by spudw2k
Link to comment
Share on other sites

the password is encrypted with its self and stored in the ini file. WHen the user needs to enter a password to start or use internal commands it decrypts the password from the ini with the typed password.. If both input and decrypted are the same then it proceeds. I am releasing the source code in its current state right now. Changes I made were to make it only pay attention to and scan for the control key.. Then when the control key is pressed it watches all alpha-numeric keys looking for a code. If you don't type anything within 5 seconds it cancels and goes back to looking for control only. If you press control while using windows with no intention of entering a command code then after 32 characters it knows there was no code entered or an incorrect code was entered and again will cancel and only watch the control key again. That is for both security and cpu cycles.

So with this, you set the password at the very start, it saves it in an ini file in a folder it creates. Then you add your actions. Those actions do not require a password to run because nobody knows what your command codes are and they cannot get a list of them because internal commands such as "list" are protected with a password and the ini file entries are all encrypted. Also the password is not kept in a variable because I clear it and only keep a hashed version which is used to encrypt the actual action entries in the ini.

Main code:

<snip>

It is a work in progress. Currently it should work fine, but if you see any issues let me know. This is mainly for my purposes but if anyone else is interested in it, they can use it too on the understanding that this is my own private work and I have no public obligations regarding this script. If people find a bug, I will try and fix it but if too much time goes by the chances get smaller because I am not known for commenting my work and after time I forget the workings and would have to study my own source again, which I would only do if something was very seriously wrong..

edit:

btw, regarding user defined functions, yes I am aware of it. My only stipulation is that it came with the autoit install, I did not have to go searching for it and manually get it, thus to me, it is part of autoit.

Edited by Melba23
Code removed
Link to comment
Share on other sites

If you are just verifying the validity of a password, as opposed to using the encrypted data itself, why not just use a hash as the stored password? It is a more secure and an accepted security practice.

Plus, I think your hash loop is a bit over kill, just my opinion. Security through application, not obfuscation.

edit: Tip

You could reduce your code by making functions for redundant tasks. (ie.password input)

Edited by spudw2k
Link to comment
Share on other sites

If you are just verifying the validity of a password, as opposed to using the encrypted data itself, why not just use a hash as the stored password? It is a more secure and an accepted security practice.

Plus, I think your hash loop is a bit over kill, just my opinion. Security through application, not obfuscation.

edit: Tip

You could reduce your code by making functions for redundant tasks. (ie.password input)

Just because it was easier at the time to attempt to decrypt the ini password entry and check it against the input the user typed. Either way the ini file has the password encrypted so it is secure regardless of it I encrypt the hash or the actual password.

Link to comment
Share on other sites

Thats cool, just explaining why I did it this way. I could do it another way but now its done, well there are many ways to script a cat lol.. Thats one thing I love about autoit, you can do things in so many ways. I like the creativity release scripting can provide.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

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