Jump to content

bobneumann

Active Members
  • Posts

    30
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

bobneumann's Achievements

Seeker

Seeker (1/7)

0

Reputation

  1. I'm trying to manipulate clipboard data that's in registered format called "Rich Text Format". (I want to do a substitution/replace: Part of the RTF code is "\cf3" and I want to change it to "\cf0") since Rich Text Format is not standard, I can't use clipget. I've gotten far enough to know that I need to refer to the memory contents by its "unsigned integer value", which is returned to me by "_clipboard_registerformat" But from there, how do I return the contents, do my search and replace, and then put my modified info back into the clipboard? Any help or guidance appreciated. Bob #include-once #include <Memory.au3> #include <WinAPI.au3> #include<clipboard.au3> $rtf_guid = _clipboard_RegisterFormat ("Rich Text Format") MsgBox(4096,"rtf guid",$rtf_guid) $contents= _clip_board_GetData($rtf_guid) MsgBox(4096,"title",$contents) Func _clip_board_GetData($rtf_guid = 1) Local $hMemory, $tData If Not _clip_board_IsFormatAvailable($rtf_guid) Then Return SetError(-1, 0, 0) If Not _clipboard_Open(0) Then Return SetError(-2, 0, 0) $hMemory = _clip_board_GetDataEx($rtf_guid) MsgBox(4096,"hmemory",$hMemory) _clipboard_Close() If $hMemory = 0 Then Return SetError(-3, 0, 0) ;Experimenting with trying to return the memory contents by converting it to text ;Switch $rtf_guid ;Case $CF_TEXT, $CF_OEMTEXT $tData = DllStructCreate("char Text[2097152]", $hMemory) ;$tData = DllStructCreate("char Text[8192]", $hMemory) ;Return DllStructGetData($tData, "Text") ;Case $CF_UNICODETEXT Return _WinAPI_WideCharToMultiByte($tData) ;Case Else ;Return $hMemory ;EndSwitch EndFunc Func _clip_board_IsFormatAvailable($rtf_guid) Local $aResult $aResult = DllCall("User32.dll", "int", "IsClipboardFormatAvailable", "int", $rtf_guid) Return $aResult[0] <> 0 EndFunc Func _Clip_Board_GetDataEx($rtf_guid = 1) Local $aResult $aResult = DllCall("User32.dll", "hwnd", "GetClipboardData", "int", $rtf_guid) Return SetError($aResult[0] = 0, 0, $aResult[0]) EndFunc
  2. I've been using AutoIt in this way for a while now, and it works very well. As far as a monitoring framework, -IMO- don't reinvent the wheel. Try something like Polymon. It already has the db structure, and all the code to "fire" various agents on a schedule to record status. I use PSTools to run my AutoIT-based "Timed activity" monitors. It does require SQLServer2005, but you can use the free/express version for limited installations. Bob
  3. With your inputk I got the script to run. I ended up looking up the enumvalues for the execute method on MSDN. ...execute(default,400,0x10) ran successfully. It didn't actually fire the stored proc. in the way I was looking for, but it did run without error. (The autoit script immediately carries on to the next step, but the stored procedure, which I expect to be running on the server/in the background, isn't. It runs for about a second then just vanishes.) I'm going to give up and set a really high .command.timeout value (10000 or so) and make the script wait.... Thanks again for your help. Bob
  4. Thanks for the reply. I try that as soon as I can. From what I've read, it is apparently significant whether the command gets passed with parentheses. (With parentheses means "I expect a response/acknowledgement" without parentheses means I don't. Is there a way to pass these without parentheses? Thanks again, Bob
  5. I'm trying to run a SQL stored procedure that will take a long time. I think if I can run the SP in async mode, it will work, but I'm having trouble getting the syntax right. Here's a VBScript example of what I want to do: Dim cmd As ADODB.Command Set cmd = New ADODB.Command cmd.ActiveConnection = "DSN = test" cmd.CommandTimeout = 180 cmd.CommandText = "sp_name" cmd.CommandType = adCmdStoredProc cmd.Execute , , adAsyncExecute Here is my AutoIT interpretation: $adoCon = ObjCreate("ADODB.Connection") $adoCon.Open ($DSN) $objCommand = ObjCreate("ADODB.Command") $objCommand.ActiveConnection = $adoCon $objCommand.CommandTimeout = 10 $objCommand.CommandText = "_init_img_tables" ;$cmdtype="adcmdstoredproc" $objCommand.CommandType = 4;(I got the value "4" as the CommandTypeEnum Value for "adCmdStoredProc' from http://www.w3schools.com/ADO/prop_comm_commandtype.asp) $objCommand.Execute = ", 400, adAsyncExecute";(See http://www.w3schools.com/ADO/met_comm_execute.asp) I want to run " $objCommand.execute , 400, adAsyncExecute " which means execute <no return value>,<parameter input of "400">,<with Option "adAsyncExecute"> the console output is: C:\Program Files\autoit\test.au3 (324) : ==> The requested action with this object has failed.: $objCommand.Execute = ", 400, adAsyncExecute" $objCommand.Execute = ", 400, adAsyncExecute"^ ERROR I can successfully use the "execute" method plain. But how do I format the AutoIT script in order to pass these options? Thanks in advance, Bob
  6. I'm trying to run a SQL stored procedure that will take a long time. I think if I can run the SP in async mode, it will work, but I'm having trouble getting the syntax right. Here's a VBScript example of what I want to do: Dim cmd As ADODB.Command Set cmd = New ADODB.Command cmd.ActiveConnection = "DSN = test" cmd.CommandTimeout = 180 cmd.CommandText = "sp_name" cmd.CommandType = adCmdStoredProc cmd.Execute , , adAsyncExecute Here is my AutoIT interpretation: $adoCon = ObjCreate("ADODB.Connection") $adoCon.Open ($DSN) $objCommand = ObjCreate("ADODB.Command") $objCommand.ActiveConnection = $adoCon $objCommand.CommandTimeout = 10 $objCommand.CommandText = "_init_img_tables" ;$cmdtype="adcmdstoredproc" $objCommand.CommandType = 4;(I got the value "4" as the CommandTypeEnum Value for "adCmdStoredProc' from http://www.w3schools.com/ADO/prop_comm_commandtype.asp) $objCommand.Execute = ", 400, adAsyncExecute";(See http://www.w3schools.com/ADO/met_comm_execute.asp) I want ..".execute , , adAsyncExecute" which means execute <no return value>,<parameter in is "400">,<with Option "adAsyncExecute"> the console output is: C:\Program Files\autoit\test.au3 (324) : ==> The requested action with this object has failed.: $objCommand.Execute = ", 400, adAsyncExecute" $objCommand.Execute = ", 400, adAsyncExecute"^ ERROR I can successfully use the "execute" method "Plain". But how do I use it with these options? Thanks in advance, Bob
  7. Ptrex, Thanks for taking the time to convert the scripts. The script kept giving me an error every time, and I'm trying to learn how this COM interface works. Here's what I've found: right after the instruction to actually produce the output file, (.cPrintfile cStr(ifname)), the original VBScript said: c = 0 Do While (ReadyState = 0) and (c < (maxTime * 1000 / sleepTime)) c = c + 1 Wscript.Sleep sleepTime Loop If ReadyState = 0 then MsgBox "Converting: " & ifname & vbcrlf & vbcrlf & _ "An error is occured: Time is up!", vbExclamation + vbSystemModal, AppTitle Exit For End If So, in human speak: "Keep working (on the "Print" process) until "ReadyState" is no longer zero, or the timeout expires. If the timeout has expired, then display an error." What I didn't see is how "ReadyState" could ever change, because the only other reference to readystate is in a subroutine: Public Sub PDFCreator_eReady() ReadyState = 1 End Sub But there is no reference to that subroutine anywhere within the script. Reading the helpfile, I came to understand that pdfcreator.exe, via the COM interface, is capable of calling back to our script saying, "I'm finished" (telling our script to launch subroutine "PDFCreator_eReady()") In order to make that work, AutoIT must be set to listen for COM events. So I changed your script in the following way: I added a "listen for events" line right after the object create: CODE $PDFCObject=ObjEvent($PDFCreator,"PDFCreator_") ; Start receiving Events. Don't forget to dim $pdfcobject above. and i modified the "Do until" statement as follows: CODE $c = 0 Do $c = $c + 1 Sleep ($sleepTime) Until ($ReadyState <> 0) or ($c >= ($maxTime * 1000 / $sleepTime)) It's working fine for me now. Do I understand this correctly? (Complete code below) Bob CODE AutoItSetOption("MustDeclareVars", 1) Const $maxTime = 30 ; in seconds Const $sleepTime = 250 ; in milliseconds Dim $objArgs, $ifname, $fso, $PDFCreator, $DefaultPrinter, $ReadyState, _ $i, $c, $AppTitle, $Scriptname, $ScriptBasename,$PDFCObject $fso = ObjCreate("Scripting.FileSystemObject") $Scriptname = $fso.GetFileName(@ScriptFullPath) $ScriptBasename = $fso.GetFileName(@ScriptFullPath) $AppTitle = "PDFCreator - " & $ScriptBasename $PDFCreator = ObjCreate("PDFCreator.clsPDFCreator") $PDFCreator.cStart ("/NoProcessingAtStartup") $PDFCObject=ObjEvent($PDFCreator,"PDFCreator_") ; Start receiving Events. With $PDFCreator .cOption("UseAutosave") = 1 .cOption("UseAutosaveDirectory") = 1 .cOption("AutosaveFormat") = 5 ; 0=PDF, 1=PNG, 2=JPG, 3=BMP, 4=PCX, 5=TIFF, 6=PS, 7= EPS, 8=ASCII .cOption("BitmapResolution") = 150 .cOption("TiffColorscount") = 2 $DefaultPrinter = .cDefaultprinter .cDefaultprinter = "PDFCreator" .cClearcache() EndWith ; For $i = 0 to $objArgs.Count - 1 With $PDFCreator $ifname = "C:\ss.rtf" ;$objArgs($i) If Not $fso.FileExists($ifname) Then MsgBox (0,"Error","Can't find the file: " & $ifname & @CR & $AppTitle) Exit EndIf If Not .cIsPrintable($ifname) Then ConsoleWrite("Converting: " & $ifname & @CRLF & @CRLF & _ "An error is occured: File is not printable!" & @CRLF & $AppTitle & @CR) EndIf $ReadyState = 0 .cOption("AutosaveDirectory") = $fso.GetParentFolderName($ifname) .cOption("AutosaveFilename") = $fso.GetBaseName($ifname) .cPrintfile($ifname) .cPrinterStop = 0 $c = 0 Do $c = $c + 1 Sleep ($sleepTime) Until ($ReadyState <> 0) or ($c >= ($maxTime * 1000 / $sleepTime)) If $ReadyState = 0 then ConsoleWrite("Converting: " & $ifname & @CRLF & @CRLF & _ "An error is occured: File is not printable!" & @CRLF & $AppTitle & @CR) Exit EndIf EndWith ;Next With $PDFCreator .cDefaultprinter = $DefaultPrinter .cClearcache() Sleep (200) .cClose() EndWith ;--- $PDFCreator events --- Func PDFCreator_eReady() $ReadyState = 1 EndFunc Func PDFCreator_eError() MsgBox(0, "An error is occured!" , "Error [" & $PDFCreator.cErrorDetail("Number") & "]: " & $PDFCreator.cErrorDetail("Description")& @CR) EndFunc
  8. I would begin with PSList, which is part of PSTools. Google it.... Bob
  9. I love it. I ended up writing the functionality I wanted into a Google gadget, which uses Javascript to look up the values and Google code to rotate a graphic of a needle to the desired position. But I'd MUCH rather do it in AutoIT and have a standalone app and complete control. Thanks again. Perhaps together we can create something we both want. Bob
  10. I have a folder on a Win2k server containing 2.4 million files. I'd like to run a script that will go through the files, create subdirectories, and put those files into subdirectories, about 5000 or so per directory. The directories would be named serially. Any quick advice on the best general way to approach this problem? Thanks in advance, Bob
  11. It has to be Win2k or XP Pro, because it needs the c$ share. And your current user id has to be admin on the remote machine.
  12. http://www.autoitscript.com/forum/index.php?showtopic=53154
  13. http://www.autoitscript.com/forum/index.php?showtopic=53154
  14. http://www.autoitscript.com/forum/index.php?showtopic=53154
  15. http://www.autoitscript.com/forum/index.php?showtopic=53154
×
×
  • Create New...