Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 02/28/2013 in all areas

  1. I can't be responsible for any impact of your script or services you would run in production. | _Services_UDF v4 | | By Arcker | Run your script as a service | Req. AutoIt 3.3.8.1 min, last beta recommended ( tested in 3.3.9.21 ) |_______________________________________ ++ Preparing v5 !! Checked on 27/04/2015 <> Updated on 10/23/2013 <> Updated 07/29/2013 <> Best practices Updated 24/02/2012 -- Removed GUI code, and old codes. == Warning : 26/02/2012 <> New Version (v3 ) : 29/07/2013 | Thx to ShminkyBoy, wraithdu, Udgeen and HolmesShelock for their great contributions. Special thx to bitboy, Downloads see end of this post : ServiceExample_v4, Services.au3, ServicesConstants.au3 Presentation Here is my _Service _ UDF With this UDF, you can compile your autoit script and run it as service. Any comments are welcome. Hope you'll like it, 1 - changelog Update V4 : 23/10/2013,27/04/2015 Update : V3 on 29/07/2013 Compile the service example to see how to do then you can use the main function for your proper scriptChoose an appropriate location and copy the script here.open a command prompt, and execute the compiled script with option –I ( must be admin right since vista )start / execute "services.msc" . You will see a service called "Autoit_service". you can execute "sc query" in a command prompt too.Launch it : it will run the previous compile script. The main function will be executed after the service_init.stop and relaunch the service as you wish. Examples / Session Change / uses v1 (lock, logon, etc) By HolmesShelock. Awesome work. Edit : this example doesn't use v2 or v3 method SessionChange Service.zip Example output to give you an idea Examples demos Synoptic And for End Users, I've tried to explain the service control manager and the way it works with programs. see below Best Practice, by arcker : /! please read this if you encounter stability issues I've had to rework on services.au3 to reflect threadsafe. Threadsafe means each dll call must be on "dllopened" instead of calling dll directly for example, if you need a function in kernel32.dll, you have to open it and call it after. That's contraignant since a lot of integrated functions in autoit are not programmed this way. If you take my services.au3, at the end, you'll see reworked function to handle this change. I've not tried services for a while, since i don't need it for now, but i can help you only if your provide whole script, to see how you call every functions. I can tell that fix stability issues in callback, but i don't think it's need for your script, as far as you don't use callback. Best Practice, by udgeen : Good news! Probably i've found the working method of integrating service.au3 with other projects I realised it after ASock.au3 project by Zatorg (please, sorry if im wrong) - ASock is asynck socket - tcp on event (uses ws2_32.dll). Asock & sqlite didnt work together. The only reason for that was..._ArrayDisplay() func with gui!!! Ok. I made special sqlite.au3 without dependences. It works, but my udf seemed too be much heavy to use at another project. Few weeks ago I returned to service.au3 and found TCP UDF, Event driven project based on ASock.au3. It seemed to work as example, but didn't work at all as service. In my variant of service_example.au3 i posted msdn words about service_main procedure, that it must contain all global vars of project I'll try to post that project as an another service_example.au3 in some weeks here. If it will works. Some advice: use SysInternals Process Explorer (free gui based), or kill.exe from support tools to stop suspended service process. U can start-stop service even net start/net stop commands. Use file logging while debuging. No need to install-uninstall service after every recompilation: only stop, recompile, start. See, if it was suspended (while stopping) - kill process. The only reason not to stop service correctly i've found for today is unclean exit: opened sockets, maybe some dlls. Edit : Arcker note: too bad, that would be too easy. unclean exit is not due to opened dll, but by some more internal exit checks or something. FAQ. 1 - Hey, I've got error 1063 or error 0, what does that mean ? It simply means that you intend to run your script in scite or directly by executing it. Your script has to be installed as service and run from it. Several ways to do it : You have to combine all Globals in one place: for example at the the begining. You have to make it with other udfs too... silly workThen sort Global Const and other Global statements. If u see something like global $x = 1 do that way: global $x leeve at top. $x =1 insert into module's (udf or project) Init func.U have to do it even with standart udf... or use only necessary functions from it in your own include. Or... maybe u have another plan?Try to build your project with modified udfs - does it works now? Hmm... But it have to Maybe later after everything will work fine i'll say "msdn is wrong, microsoft lies"... But maybe i'll say that microsoft - is not so bad, because autoit works in itnet start "yourservicename"Services.mscUse API provided _Service_start, Service_stop. 2 - I want to make a GUI ! It's not possible in a service. Create another process and communicate with your service by using IPC. 3 - I've to let the main function that way ? That's contraignant. Hey, a script intended to run as service is special no ? Autoit is not C++. The only way to have a "Main" in autoit is to have a function. If you find another way, please share it ServiceExample_ThreadSafe.au3 Services.au3 ServiceExample_v4.au3 ServicesConstants.au3
    1 point
  2. One of the main issues AutoIt coder could have is lack of built-in data compression mechanism. Doing it "manually" is not an option because of the slowness of the interpretter. So, it's either using third party dlls (whatever) or some Windows API that exposes the funcionality. In this post I will compress data using well known GDI+. That's graphical library, so it's not straightforward approach. First I'm making BITMAP out of data and then convert that image into a PNG. PNG format includes form of compression, so at the end what's get is compressed data. Compression level is not very high compared to other methods, but considering everything - who cares . Of course that compressing string "ABC" will not make much sense and will result in, IDK 150 bytes of output because PNG includes metadata that take space, but for data in sizes of more than few KB you will see the difference. Besides you will see how your data looks if it's taken to be a picture. Script will create PNG out of itself called Test_Image.png and then read it and print to console: GDIP_Compress.au3
    1 point
  3. Jos

    Problem with scite

    It probably has something to do with the way the workdir is set when SciTE is shelled via the explorer OPEN option. Open another file in another directory and the issue is gone for the first opened file/directory I see the same issue as the OP on Win7 prof x64 with SciTE 3.2.5.
    1 point
  4. DiOgO, Delighted I could help - and that you understood my explanations. M23
    1 point
  5. You must not call DeleteDC for hdc.
    1 point
  6. UEZ

    Cleaning up ( SelectObject )

    Something like that maybe in AutoIt notation: $hDC = _WinAPI_GetDC(0) $hdcMEM = _WinAPI_CreateCompatibleDC($hDC) $hBitmap = _WinAPI_CreateCompatibleBitmap($hDC, $iWidth, $iHeight) _WinAPI_SelectObject ($hdcMEM, $hBitmap) _WinAPI_DeleteObject($hDC) _WinAPI_ReleaseDC(0, $hDC) _WinAPI_DeleteDC($hdcMEM) _WinAPI_DeleteObject($hBitmap) _WinAPI_DeleteDC($hDC) Br, UEZ
    1 point
  7. Usually if you don't have the use for replaced you do this: ::DeleteObject(::SelectObject(hdcMEM,hBitmap)); ... And you should call ReleaseDC for hdc.
    1 point
  8. DiOgO, No - remember that we are only interested in the "bottom" 16 bits - we want the "top" 16 bits to be set to 0. BitShift(16) puts the "Hi" 16 bits into the "bottom" 16 and fills the "top" with 0's. If you were to useBitShift(-16) you would put the "Lo" 16 bits into the "top" 16 and fill the "bottom with 0's - not at all what we want. That is why you need the BitAnd to mask out the "top" bits with 0's and leave the "bottom" alone. M23
    1 point
  9. That was an example, the quoted part shows you what you need to use for when it's on battery (DC). Although, this might be a better method if you want it for just the script you're currently running. #include <WINAPIEx.au3> _WinAPI_SetThreadExecutionState(BitOr($ES_CONTINUOUS, $ES_DISPLAY_REQUIRED)) EDIT: The WINAPIEx.au3 is included in AutoIt version 3.3.9.4 (beta), or you can download it from if you're running a prior version.
    1 point
  10. retaly, I think this should solve those 2 problems - look for the <<<<<<<< lines as usual. #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <EditConstants.au3> #include <ListBoxConstants.au3> $Form1 = GUICreate("Form1", 615, 438, 192, 124) $Edit1 = GUICtrlCreateEdit("", 30, 72, 445, 265) $mylist = GUICtrlCreateList("", 480, 72, 121, 265) GUICtrlSetData(-1, 'Test1 ""|Test2|Test3') ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< $button = GUICtrlCreateButton("Exit", 280, 368, 75, 25) GUISetState(@SW_SHOW) GUIRegisterMsg($WM_COMMAND, "_WM_COMMAND") While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $button Exit EndSwitch WEnd Func _WM_COMMAND($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $lParam $iIDFrom = BitAND($wParam, 0xFFFF) ; Low Word $iCode = BitShift($wParam, 16) ; Hi Word Switch $iCode Case $LBN_DBLCLK Switch $iIDFrom Case $mylist ; Read current content $sData = GUICtrlRead($Edit1) ;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ; What are we adding $sAdd = GUICtrlRead($mylist) ; As long as we clicked on a list item If $sAdd Then ; Add the clicke4ed item $sData &= GUICtrlRead($mylist) & @CRLF ; Reset the edit content GUICtrlSetData($Edit1, $sData) EndIf EndSwitch EndSwitch EndFunc Is that how you want it? M23
    1 point
  11. what am I suppose to use for adding data into multiple columns/rows for an Array..?? since _ArrayAdd only works for 1 dimensional arrays..??
    1 point
  12. Wow!!! Outstanding stuff. Marvellous work, Melba... You, Sir, are top notch:graduated:
    1 point
×
×
  • Create New...