dv8 Posted March 10, 2006 Author Share Posted March 10, 2006 Thanks. I suppose one could use just Run(@ScriptFullPath) in the example without using Beta, but prevents Au3 execution as when UnCompiled. @dv8 It is If conditional on whether a 2nd instance starts or not. Using the switch restart will allow a 2nd instance and close the first. You cannot have it both ways of executing a 2nd instance and not allowing it. Edit: If you want, have a look at FAQ 14 and apply it within the restart part of the If block. Sorry :"> I see it now. This suits me perfect!!! Thank you very much ! Free Remote Desktop Software For Windows Link to comment Share on other sites More sharing options...
MHz Posted March 10, 2006 Share Posted March 10, 2006 (edited) Your Welcome. And thanks SmOke_N for creating the good example to show the idea working. Edited March 10, 2006 by MHz Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted March 10, 2006 Moderators Share Posted March 10, 2006 (edited) Your Welcome.And thanks SmOke_N for creating the good example to show the idea working.No thank you for taking the time... This is Awesome... (Don't know if I'll ever need it), but a hell of a lot better than my offering!! (Even though I believe you wrote the _SelfDelete() too?! ) Edited March 10, 2006 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
dv8 Posted March 10, 2006 Author Share Posted March 10, 2006 (edited) Here is the fruit of all this:This a small program (HotKey.au3) to define and use (up to 64) HotKeys for any file on your system. expandcollapse popup;HotKey.au3 #include <GuiConstants.au3> If Not $CMDLINE[0] Then If UBound(ProcessList(@ScriptName)) > 2 Then Exit ElseIf $CMDLINE[1] <> '/restart' Then Exit EndIf Global $HK=CheckINI() Opt("TrayMenuMode",1) Opt("TrayOnEventMode",1) $Settings_tray = TrayCreateItem("Settings") TrayItemSetOnEvent($Settings_tray,"_Settings") $Restart_tray = TrayCreateItem("Restart") TrayItemSetOnEvent($Restart_tray,"_Restart") $exit_tray = TrayCreateItem("Exit (Ctrl+Alt+X)") TrayItemSetOnEvent($exit_tray,"_Exit") TraySetState() HotKeySet ( "^!x","_Exit") For $i=1 to $HK[0][0] HotKeySet ( "^"&$HK[$i][0],"StartEvent") Next While 1 sleep (100) WEnd Func StartEvent() $Pressed=StringTrimLeft(@HotKeyPressed,1) For $i=1 to $HK[0][0] If $Pressed=$HK[$i][0] Then DllCall("shell32.dll", "long", "ShellExecute", "hwnd", 0, "string", "", "string",$HK[$i][1], "string", "", "string", "", "long", @SW_SHOWNORMAL) exitloop EndIf Next EndFunc Func CheckINI() $var = IniReadSection(@ScriptDir&"\HotKey.ini", "HOTKEYS") If @error Then MsgBox(16,"HotKey","Error! Probably missing INI file.") exit ElseIf $var[0][0]>64 Then MsgBox(16,"HotKey","You have defined more than 64 (max)hot keys!") exit Else For $i=1 to $var[0][0] If StringLen($var[$i][0])>2 Then MsgBox(16,"HotKey","Error! The KEY """&$var[$i][0]&""" in the INI file consists of more than 2 sybmols!") exit ElseIf $var[$i][0]="!x" Then MsgBox(16,"HotKey","Error! The combination ""!x"" is for exiting the HotKey program!") exit ElseIf $var[$i][0]="" Then MsgBox(16,"HotKey","Error! Missing key for the value """&$var[$i][1]&""" in the INI file!") exit ElseIf $var[$i][1]="" Then MsgBox(16,"HotKey","Error! The key """&$var[$i][0]&""" in the INI file has no value!") exit EndIf Next return($var) EndIf EndFunc Func _Settings() Run("notepad.exe "&@ScriptDir&"\HotKey.ini") EndFunc Func _Exit() exit EndFunc Func _Restart() Run(@ScriptFullPath& " /restart") exit EndFuncAnd here is the sample INI file:;HotKey.ini [HOTKEYS] +c="C:\Program Files\ConTEXT\ConTEXT.exe" +f="C:\Program Files\Mozilla Firefox\firefox.exe" +a=C:\Program Files\AutoIt3\beta\AutoIt3.chm +p=mspaint !n=c:\New text document.txtThe fist key of the combination is always the CTRL key (the program puts it automaticaly)"+" is for SHIFT"!" is for ALTI hope this will be as usefull to anybody as it is to me. Edited March 10, 2006 by dv8 Free Remote Desktop Software For Windows Link to comment Share on other sites More sharing options...
tonedeaf Posted March 10, 2006 Share Posted March 10, 2006 Not happen that way, because there can be only one instance of it. it has the line: If UBound(ProcessList(@ScriptName)) > 2 Then Exit That's because it has many HOTKEYS and if there is another instance the hotkeys mess up. Then, unregister the hot keys before starting another instance Link to comment Share on other sites More sharing options...
MHz Posted March 10, 2006 Share Posted March 10, 2006 Here is the fruit of all this:This a small program (HotKey.au3) to define and use (up to 64) HotKeys for any file on your system. The fist key of the combination is always the CTRL key (the program puts it automaticaly)"+" is for SHIFT"!" is for ALTI hope this will be as usefull to anybody as it is to me. Hmm, sounds interesting. May take me alittle time to set a test with configuring it. If it is proven good to share by you, then you could post it in the Script'n'Scraps forum to share with the AutoIt community. Link to comment Share on other sites More sharing options...
dv8 Posted March 10, 2006 Author Share Posted March 10, 2006 Hmm, sounds interesting. May take me alittle time to set a test with configuring it. If it is proven good to share by you, then you could post it in the Script'n'Scraps forum to share with the AutoIt community. 10x I'll be glad to do that.Test it if you have time and post any suggestions and remarks Free Remote Desktop Software For Windows Link to comment Share on other sites More sharing options...
dv8 Posted March 12, 2006 Author Share Posted March 12, 2006 This script is now posted HERE. Free Remote Desktop Software For Windows 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