JackyChan Posted March 2, 2009 Posted March 2, 2009 (edited) I have 2 scripts:Service UDF http://www.autoitscript.com/forum/index.php?showtopic=80201expandcollapse popup#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Version=Beta #AutoIt3Wrapper_Change2CUI=y #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** ; Example of using service UDF to make an exe possibly runeed as a service ; By Arcker ; 10/09/2008 #include<Service.au3> $sServiceName = "Autoit_Service" If $cmdline[0] > 0 Then Switch $cmdline[1] Case "install", "-i", "/i" InstallService() Case "remove", "-u", "/u", "uninstall" RemoveService() Case Else ConsoleWrite(" - - - Help - - - " & @crlf) ConsoleWrite("params : " & @crlf) ConsoleWrite(" -i : install service" & @crlf) ConsoleWrite(" -u : remove service" & @crlf) ConsoleWrite(" - - - - - - - - " & @crlf) Exit ;start service. EndSwitch EndIf _Service_init($sServiceName) InstallService() _SelfRun($sServiceName,"start") func main() While 1 MsgBox(0, "", "Work") Sleep(1000) WEnd EndFunc Func InstallService() ConsoleWrite("Installing service, please wait" & @CRLF) _Service_Create("", $sServiceName, "Autoit Service Test", '"' & @ScriptFullPath & '"') If @error Then ConsoleWrite("Problem installing service, Error number is " & @error & @CRLF & " message : " & _WinAPI_GetLastErrorMessage()) Else ConsoleWrite("Installation of service successful") EndIf EndFunc ;==>InstallService Func RemoveService() _StopService("", $sServiceName) _DeleteService("", $sServiceName) if not @error then ConsoleWrite("service removed successfully" & @crlf) Exit EndFunc ;==>RemoveService Func _SelfRun($servicename,$action) $sCmdFile = 'sc ' & $action & ' "' & $servicename & '"' & @CRLF & 'del ' & @TempDir & '\runsvc.bat' FileWrite(@TempDir & "\runsvc.bat", $sCmdFile) Run(@TempDir & "\runsvc.bat", @TempDir, @SW_HIDE) Exit EndFuncoÝ÷ ØCjëh×6$notepad_handle = 0 While 1 If $notepad_handle <> WinExists ('Untitled') AND WinExists ('Untitled') <> 0 Then MsgBox(0, '1', 'Once') $notepad_handle = WinExists ('Untitled') EndIf WEndoÝ÷ ØZ§"h±yݬr¸©¶Æ®¶sb5&Vvöâ²¢¢¢¢F&V7FfW27&VFVB'WFôC5w&W%ôuT¢¢¢ ¢4WFôC5w&W%õfW'6öãÔ&WF¢4WFôC5w&W%ô6ævS$5T×¢4VæE&Vvöâ²¢¢¢¢F&V7FfW27&VFVB'WFôC5w&W%ôuT¢¢¢ £²WׯRöbW6ær6W'f6RTDbFòÖ¶RâWR÷76&Ç'VæVVB26W'f6P£²'&6¶W £²óó#¢6æ6ÇVFRfÇCµ6W'f6RæS2fwC°¢b33c·56W'f6TæÖRÒgV÷C´WFöEõ6W'f6RgV÷C°¤bb33c¶6ÖFÆæU³ÒfwC²FVà 7vF6b33c¶6ÖFÆæU³Ð 66RgV÷C¶ç7FÆÂgV÷C²ÂgV÷C²ÖgV÷C²ÂgV÷C²ögV÷C° ç7FÆÅ6W'f6R 66RgV÷C·&VÖ÷fRgV÷C²ÂgV÷C²×RgV÷C²ÂgV÷C²÷RgV÷C²ÂgV÷C·Væç7FÆÂgV÷C° &VÖ÷fU6W'f6R 66RVÇ6P 6öç6öÆUw&FRgV÷C²ÒÒÒVÇÒÒÒgV÷C²fײ7&Æb 6öç6öÆUw&FRgV÷C·&×2¢gV÷C²fײ7&Æb 6öç6öÆUw&FRgV÷C²Ö¢ç7FÆÂ6W'f6RgV÷C²fײ7&Æb 6öç6öÆUw&FRgV÷C²×R¢&VÖ÷fR6W'f6RgV÷C²fײ7&Æb 6öç6öÆUw&FRgV÷C²ÒÒÒÒÒÒÒÒgV÷C²fײ7&Æb W@ ·7F'B6W'f6Rà VæE7vF6¤VæD`¥õ6W'f6UöæBb33c·56W'f6TæÖR¤ç7FÆÅ6W'f6R¥õ6VÆe'Vâb33c·56W'f6TæÖRÂgV÷C·7F'BgV÷C²¦gVæ2Öâ b33c¶æ÷FWEöæFÆRÒ¥vÆR¢bb33c¶æ÷FWEöæFÆRfÇC²fwC²väW7G2b33µVçFFÆVBb33²äBväW7G2b33µVçFFÆVBb33²fÇC²fwC²FVà¢×6t&÷Âb33³b33²Âb33´öæ6Rb33²¢b33c¶æ÷FWEöæFÆRÒväW7G2b33µVçFFÆVBb33²¢VæD`¥tVæ@¤VæDgVæ0 ¤gVæ2ç7FÆÅ6W'f6R 6öç6öÆUw&FRgV÷C´ç7FÆÆær6W'f6RÂÆV6RvBgV÷C²fײ5$Äb õ6W'f6Uô7&VFRgV÷C²gV÷C²Âb33c·56W'f6TæÖRÂgV÷C´WFöB6W'f6RFW7BgV÷C²Âb33²gV÷C²b33²fײ67&DgVÆÅFfײb33²gV÷C²b33² bW'&÷"FVà 6öç6öÆUw&FRgV÷Cµ&ö&ÆVÒç7FÆÆær6W'f6RÂW'&÷"çVÖ&W"2gV÷C²fײW'&÷"fײ5$ÄbfײgV÷C²ÖW76vR¢gV÷C²fײõväôvWDÆ7DW'&÷$ÖW76vR VÇ6P 6öç6öÆUw&FRgV÷C´ç7FÆÆFöâöb6W'f6R7V66W76gVÂgV÷C² VæD` W@¤VæDgVæ2³ÓÒfwC´ç7FÆÅ6W'f6P¤gVæ2&VÖ÷fU6W'f6R õ7F÷6W'f6RgV÷C²gV÷C²Âb33c·56W'f6TæÖR ôFVÆWFU6W'f6RgV÷C²gV÷C²Âb33c·56W'f6TæÖR bæ÷BW'&÷"FVâ6öç6öÆUw&FRgV÷C·6W'f6R&VÖ÷fVB7V66W76gVÆÇgV÷C²fײ7&Æb W@¤VæDgVæ2³ÓÒfwCµ&VÖ÷fU6W'f6P¤gVæ2õ6VÆe'Vâb33c·6W'f6VæÖRÂb33c¶7Föâ¢b33c·46ÖDfÆRÒb33·62b33²fײb33c¶7Föâfײb33²gV÷C²b33²fײb33c·6W'f6VæÖRfײb33²gV÷C²b33²fײ5$Äbfײb33¶FVÂb33²fײFV×F"fײb33²b3#·'Vç7f2æ&Bb33°¢fÆUw&FRFV×F"fײgV÷C²b3#·'Vç7f2æ&BgV÷C²Âb33c·46ÖDfÆR¢'VâFV×F"fײgV÷C²b3#·'Vç7f2æ&BgV÷C²ÂFV×F"Â5uôDR W@¤VæDgVæ0If you don't mix 2 scripts. Both will work.Please help me mix 2 scriptsThanks Edited March 2, 2009 by JackyChan
Zedna Posted March 2, 2009 Posted March 2, 2009 You declared func main() but it isn't called from any place. Resources UDF ResourcesEx UDF AutoIt Forum Search
JackyChan Posted March 5, 2009 Author Posted March 5, 2009 You declared func main() but it isn't called from any place.Oh. You wrong.Func main() in Service UDF!Please search Service UDF and read
martin Posted March 5, 2009 Posted March 5, 2009 Oh. You wrong.Func main() in Service UDF!Please search Service UDF and read Oh no he isn't. You will find that the function main() is in the example in that post. It is not in the udf. Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
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