Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 06/01/2017 in all areas

  1. Example: $aManager = DllCall("advapi32.dll", "ptr", "OpenSCManager", "long", 0, "long", 0, "long", 0xf003f) $aService = DllCall("advapi32.dll", "ptr", "OpenService", "long", $aManager[0], "str", "Alerter", "long", 0xf003f) $serviceDescription = DllStructCreate("ptr") $sDescription = DllStructCreate("char[260]") DllStructSetData($sDescription, 1, "Notifies selected users and computers of administrative alerts. If the service is stopped, programs that use administrative alerts will not receive them. If this service is disabled, any services that explicitly depend on it will fail to start.") DllStructSetData($serviceDescription, 1, DllStructGetPtr($sDescription)) DllCall("advapi32.dll", "int", "ChangeServiceConfig2", "long", $aService[0], "long", 1, "long", DllStructGetPtr($serviceDescription)) DllCall("advapi32.dll", "ptr", "CloseServiceHandle", "long", $aService[0]) DllCall("advapi32.dll", "ptr", "CloseServiceHandle", "long", $aManager[0]) Change "Alerter" to the name of your service. Change "Notifies ..." to the description you want. WBD
    2 points
  2. Wrote a command line utility which will unblock folders and files passed to it as a parameter. You can pass as many files/folders as you want as a parameter. If function detects "-r" or "/r" as first parameter, will unblock files recursively for directories that are passed to it. Will perform following actions: 1) determine version of powershell installed on computer 2) if powershell version is greater than or equal to 3, will use powershell to unblock the files. Otherwise, will download "streams.exe" for 32-bit systems and "streams64.exe" for 64-bits systems from sysinternals live server and unblock files by deleting the alternate streams on indicated folders. #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_UseX64=y #AutoIt3Wrapper_Change2CUI=y #AutoIt3Wrapper_Res_SaveSource=y #AutoIt3Wrapper_Res_Language=1033 #AutoIt3Wrapper_Res_requestedExecutionLevel=requireAdministrator #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** ; *** Start added by AutoIt3Wrapper *** #include <InetConstants.au3> ; *** End added by AutoIt3Wrapper *** ; *** Start added by AutoIt3Wrapper *** #include <AutoItConstants.au3> #include <WinAPIShPath.au3> ; *** End added by AutoIt3Wrapper *** #cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.15.0 (Beta) Author: myName Script Function: Template AutoIt script. #ce ---------------------------------------------------------------------------- ; Script Start - Add your code below here #include <Array.au3> #include <File.au3> #include <WinAPIFiles.au3> Opt("ExpandEnvStrings", 1) $aCmdLine = _WinAPI_CommandLineToArgv($CmdLineRaw) $recurs = False If $aCmdLine[1] = "/?" And Int($aCmdLine[0]) = 1 Then ConsoleWrite(@CRLF & @CRLF & @TAB & @TAB & @TAB & @TAB & @TAB & "Unblock Files Command Line Utility" & @CRLF & @CRLF & "Unblock files." & @CRLF & "new_unblock.exe [/r] [[[drive:][path][filename]0] .... [[drive:][path][filename]n]]" & _ @CRLF & @CRLF & "/r" & @TAB & "if any of the paths that are passed to the tool are directories, this switch will recursively unblock all files within the directory." & _ @CRLF & @CRLF & "[[[drive:][path][filename]0] .... [[drive:][path][filename]n]]" & @TAB & "The paths that are passed to the tool to be unblocked. These paths can be files or folders. If a folder is specified, only the files in the root of that directory will be unblocked unless the /r switch is specified." & @CRLF) ElseIf $aCmdLine[1] = "/?" And Int($aCmdLine[0]) > 1 Then ConsoleWriteError('Unexpected number of arguments. For information on how to use this tool, run "new_unblock.exe /?".' & @CRLF) Else For $i = 1 To $aCmdLine[0] Step 1 If ($aCmdLine[$i] = "/r" Or $aCmdLine[$i] = "-r") And $i = 1 Then $recurs = True ContinueLoop EndIf If IsFile($aCmdLine[$i]) = 0 Then If $recurs = True Then $files = _FileListToArrayRec($aCmdLine[$i], "*", $FLTAR_FILES, $FLTAR_RECUR) Else $files = _FileListToArray($aCmdLine[$i], "*", $FLTA_FILES) EndIf For $b = 1 To $files[0] Step 1 If FileExists($aCmdLine[$i] & "\" & $files[$b] & ":Zone.Identifier") Then ConsoleWrite ( "Unblocking file " & $aCmdLine[$i] & "\" & $files[$b] & @CRLF ) _WinAPI_DeleteFile($aCmdLine[$i] & "\" & $files[$b] & ":Zone.Identifier:$DATA") Else ContinueLoop EndIf Next Else If FileExists($aCmdLine[$i] & ":Zone.Identifier") Then ConsoleWrite ( "Unblocking file " & $aCmdLine[$i] & @CRLF ) _WinAPI_DeleteFile($aCmdLine[$i] & ":Zone.Identifier:$DATA") Else ContinueLoop EndIf EndIf Next ConsoleWrite ( "DONE" & @CRLF ) EndIf Func IsFile($sFilePath) Return Number(FileExists($sFilePath) And StringInStr(FileGetAttrib($sFilePath), "D", 2, 1) = 0) EndFunc ;==>IsFile *Edit 2/3/2017: I updated the code so that, when the powershell method is used, a path that is under "Program files" or "program files (x86)" does not return an error. **EDIT: The script has been re-written so that it is able to accomplish the same functionality without any prerequisites. Only runs pure AutoIT now. A big thanks to @argumentum for the idea.
    1 point
  3. But the script would be better if it didn't have any prerequisites or dependencies, so I updated the script with the code you provided. You know it's funny, before I began work on this script, I remember doing research in order to determine how Windows flagged a file as "blocked" in order to be able to accomplish what you just showed me, but came up nil after about 30 minutes so I gave up and settled on using the prerequisite methods. The script in the main post has been updated.
    1 point
  4. ViciousXUSMC, Do you mean something like this? #include <MsgBoxConstants.au3> HotKeySet("{ESC}", "_Exit") Opt("TrayOnEventMode", 1) ; Use event trapping for tray menu Opt("TrayMenuMode", 3) ; Default tray menu items will not be shown TrayCreateItem("Func 1") TrayItemSetOnEvent(-1, "TaskbarFunc1") TrayCreateItem("Func 2") TrayItemSetOnEvent(-1, "TaskbarFunc2") While 1 Sleep(10) WEnd Func TaskbarFunc1() MsgBox($MB_SYSTEMMODAL, "TaskBar", "Func 1") EndFunc Func TaskbarFunc2() MsgBox($MB_SYSTEMMODAL, "TaskBar", "Func 2") EndFunc Func _Exit() Exit EndFunc M23
    1 point
  5. Alternative. #include <FileConstants.au3> ConsoleWrite(_ReadOffSet("1.txt",0,3) & @CRLF) Func _ReadOffSet($sFilePath,$iOffset,$iLen=1) Local $sRet="" Local $hFile=FileOpen($sFilePath,$FO_BINARY) FileSetPos($hFile,$iOffset,$FILE_BEGIN) $sRet=FileRead($hFile,$iLen) FileClose($hFile) Return $sRet EndFunc Saludos
    1 point
  6. ? Func _Offset2String($my_file, $start, $end) Local $file = FileOpen($my_file, 16) ;$FO_BINARY Local $chars = StringRegExp(FileRead($file), '[[:xdigit:]]{2}', 3) FileClose($file) Local $txt = "offset " & $start & "-" & $end & " :" &@crlf&@crlf For $i = $start to $end $txt &= Chr("0x" & $chars[$i]) Next Return $txt EndFunc Edit Certainly much easier using FileSetPos
    1 point
  7. Well, at least for me it was very informative to dig in this direction. ^^ I still investigating...
    1 point
  8. Sure no hurries... I keep on creating trial and error Examples ... Mayby we should start replacing the magic numbers by vars names, as this is more appealing and complies to better to the better coding practices... ? Some home works before we release the next version...
    1 point
  9. Something like this? #include <Array.au3> #include <File.au3> #include <MsgBoxConstants.au3> #include <Excel.au3> HotKeySet("{ESC}", "Terminate") Global $aFiles = _FileListToArray(@ScriptDir, "test*.xlsx") Global $oExcel = _Excel_Open() Global $oMasterFile = _Excel_BookNew($oExcel, 1) Global $iInvoices = 0 Global $xlup = -4162 Global $sWorkbook, $oWorkbook, $iLastRow, $oRange, $iFirstRow2Insert = 1 For $i = 1 To $aFiles[0] If $aFiles[$i] = "InvoiceCounter" Then ContinueLoop $sWorkbook = @ScriptDir & "\" & $aFiles[$i] ConsoleWrite("Processing: " & $sWorkbook & @CRLF) $oWorkbook = _Excel_BookOpen($oExcel, $sWorkbook, True) $iLastRow = $oExcel.ActiveSheet.Range("A65536").End($xlup).Row $iInvoices = $iInvoices + $iLastRow - 4 ; skip first 4 rows as they do not contain data $oRange = $oWorkbook.ActiveSheet.Range("A5:A" & $iLastRow) _Excel_RangeCopyPaste($oMasterFile.ActiveSheet, $oRange, "A" & $iFirstRow2Insert) $iFirstRow2Insert = $iFirstRow2Insert + $iLastRow - 4 _Excel_BookClose($oWorkbook, False) Next MsgBox($MB_OK, "", "Number of invoices: " & $iInvoices) Func Terminate() Exit EndFunc ;==>Terminate
    1 point
  10. Looks so much better than what I hand rolled a while back for my project. I did not find any UDF for Com Ports so I learned how it all worked and came up with my own solution. The knowledge of how the registry keys work and what not was very good to learn however.
    1 point
  11. All, Thanks for your efforts but I wouldn't want anyone to waste time on my initial question since it's no more an issue for me. However the outcome could certainly benefit to the community.
    1 point
  12. Skysnake

    ADO.au3 UDF

    I have been working with this ADO.AU3 UDF for more than a year. At the time of writing this, I am using beta 2.1.15. ADO in general allows connection to various data sources. The full documentation is available from Microsoft and a simple Google search will reveal the scope. This ADO UDF is very powerful and incorporates ideas from various other UDFs available on the Forums, such as the SQL UDF and others. The ADO UDF provides for an ADO connection using COM objects. The design is such that little knowledge of either ADO or COM is required. Combining ADO with AutoIt creates a very powerful package. The way this UDF is implemented it is not necessary to have deep ADO knowledge in order to connect and perform tasks. Since it uses ADO, in order to implement, the following is required a data source (such as a database) ODBC DNS driver and entry in the Windows Control Panel this ADO UDF #include of ADO.au3 in the user script Note that the examples should work by default. Note the connection values in each example. I have personally tested the ADO UDF on PostgreSQL databases, both locally and online, DBFs both locally and remote and briefly tested connectivity to other data sources. It all works as expected. I do not use the power of ADO to the full extent, as my needs are limited to basic reporting. The advantage is that standard SQL queries can be run over ADO to the data source - even to DBF files! The most important changes in this version 2.1.15 beta are as described below. The COM error handling makes provision for standard SQL blank result sets. This means that COM errors such as no-connection, faulty queries etc will result in a crash. Valid SQL with valid SQL responses can be processed in a manner which does not lead to a crash, but processed as a normal result. At the same time, a different implementation of the same UDF (this means you write your own part of the AutoIt code differently) means that such a blank result set may represent a blank ADO cursor, which must result in an ADO / COM error. The advantage is that a single UDF can now be implemented in different scenario's, on various data sources, with different error handling processes. I recommend this ADO.AU3 UDF to anyone wishing to connect to any external data source. Skysnake
    1 point
  13. Tyranna, How about this SplitButton example as "a compact, superior interface"? #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <ButtonConstants.au3> #include <MsgBoxConstants.au3> #include <GuiMenu.au3> $hGUI = GUICreate("Test", 500, 500) $cSplitButton = GUICtrlCreateButton("Run Auto", 10, 10, 120, 30, $BS_SPLITBUTTON) GUISetState() GUIRegisterMsg($WM_NOTIFY, "_WM_NOTIFY") While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $cSplitButton _Run_Select() EndSwitch WEnd Func _Run_Select() Switch GUICtrlRead($cSplitButton) Case "Run Auto" MsgBox($MB_SYSTEMMODAL, "Selected", "Auto") Case "Run Once" MsgBox($MB_SYSTEMMODAL, "Selected", "Once") EndSwitch EndFunc Func _Run_Menu($hCtrl) Local Enum $iOption_1 = 1000, $iOption_2 Local $hMenu = _GUICtrlMenu_CreatePopup() _GUICtrlMenu_InsertMenuItem($hMenu, 0, "Run Auto", $iOption_1) _GUICtrlMenu_InsertMenuItem($hMenu, 1, "Run Once", $iOption_2) Switch _GUICtrlMenu_TrackPopupMenu($hMenu, $hCtrl, -1, -1, 1, 1, 2) Case $iOption_1 GUICtrlSetData($cSplitButton, "Run Auto") Case $iOption_2 GUICtrlSetData($cSplitButton, "Run Once") EndSwitch _GUICtrlMenu_DestroyMenu($hMenu) _Run_Select() EndFunc ;==>List_Insert_Menu Func _WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam Local $tStruct = DllStructCreate($tagNMHDR, $lParam) If @error Then Return Switch DllStructGetData($tStruct, "Code") Case $BCN_DROPDOWN _Run_Menu(DllStructGetData($tStruct, "hWndFrom")) EndSwitch EndFunc M23
    1 point
  14. mikell

    Environment related bugs?

    Helpfile says ExpandVarStrings . 1 = expand variables (when in this mode and you want to use a literal $ or @ then double it up So you might try this #include <AutoItConstants.au3> Opt("ExpandEnvStrings", 1) ;0=don't expand, 1=do expand Opt("ExpandVarStrings", 1) ;0=don't expand, 1=do expand Local $windir = EnvGet('WinDir') ;; "windir" EnvGet is case insensitive ConsoleWrite("Works: temp = %temp% or %TMP% @CRLF@") ConsoleWrite("Works: $$windir = " & $windir & @CRLF) ConsoleWrite("Fails: @@WindowsDir = @WindowsDir@ @CRLF@" & @CRLF) ;; @WindowsDir ConsoleWrite("Fails: $$windir = $windir$ @CRLF@" & @CRLF) ;; $windir ConsoleWrite("Fails: %%windir = %windir% @CRLF@" & @CRLF) ;; %windir
    1 point
  15. steveeye

    [SOLVED] Noob Question

    the string will work both ways . on ints and decs.
    1 point
  16. ^^ "Optional" doesn't mean optional in such way. What it really means is that (C/C++) compiler will generate the argument for programmer if omitted - as per definition. Obviously, AutoIt is not C compiler, therefore "optional" means nothing here. It should be: DllCall("C:\temp\test.dll", "int", "test_sender_send_values", _     "str", "192.168.1.2", _     "ushort", 80, _     "str", "192.168.1.3", _     "ptr", DllStructGetPtr($struct), _     "int", 1, _ "ptr*", 0) If that fails for some reason, then calling convention should be changed to cdecl ("int:cdecl"), because it's not obvious from the OP what TEST_API is.
    1 point
  17. GogoTraining

    laptop battery

    Sometimes when we using laptops for continuously long time it would happen so.
    1 point
  18. I think the string comparison converts the character to its decimal equivalent before comparing... just a guess, I have not done any SQL
    1 point
  19. water

    [SOLVED] Noob Question

    I know nothing about SQL but shouldn't be and Amount > '0' changed to and Amount > 0 for a numeric comparison?
    1 point
×
×
  • Create New...