Run your AHK_L code then open e.g. Task Manager and close it, MsgBox is displayed.

COM Object Reference [AutoHotkey v1.1+]
Started by
jethrow
, Aug 17 2010 07:08 AM
233 replies to this topic
#121
-
Posted 31 March 2011 - 07:34 PM
![COM Object Reference [AutoHotkey v1.1+]: post #121](http://autohotkey.com/board/public/style_images/ortem/icon_share.png)
my mistake
seems like it works fine, i just forgot to make objects global
here is a final code for logging closed processes:
seems like it works fine, i just forgot to make objects global
here is a final code for logging closed processes:
EnableDeleteNotification() { global winmgmts := ComObjGet("winmgmts:") deleteSink := ComObjCreate("WbemScripting.SWbemSink") ComObjConnect(deleteSink,"ProcessDelete_") interval := 1 winmgmts.ExecNotificationQueryAsync(deleteSink, "SELECT * FROM __InstanceDeletionEvent WITHIN " . interval . " WHERE TargetInstance ISA 'Win32_Process'") return } ; Called when a process terminates: ProcessDelete_OnObjectReady(objWbemObject,objWbemAsyncContext) { global local proc proc := objWbemObject.TargetInstance ;http://msdn.microsoft.com/en-us/library/aa394372.aspx proc_cmd := proc.CommandLine proc_name := proc.Name proc_exe := proc.ExecutablePath proc_pID := proc.ParentProcessID proc_ID := proc.Handle msgbox % proc_cmd "`n" proc_exe "`n" proc_name "`n" proc_ID "`n" proc_pID return } StopClProcNotify() { global ObjRelease(winmgmts) ObjRelease(deleteSink) winmgmts := deleteSink := "" return }
#122
-
Posted 31 March 2011 - 08:35 PM
![COM Object Reference [AutoHotkey v1.1+]: post #122](http://autohotkey.com/board/public/style_images/ortem/icon_share.png)
You don't need to use ObjRelease, it is automatically handled by AHK_L.
#123
-
Posted 31 March 2011 - 08:45 PM
![COM Object Reference [AutoHotkey v1.1+]: post #123](http://autohotkey.com/board/public/style_images/ortem/icon_share.png)
how can i call object method similar to this VBScript code?
oWB.Sheets.Add("",oWB.Sheets(oWB.Sheets.Count))
oWB.Sheets.Add(0,oWB.Sheets(oWB.Sheets.Count))
oWB.Sheets.Add("After",oWB.Sheets(oWB.Sheets.Count))
<!-- m -->http://msdn.microsof...ry ... 12).aspx<!-- m -->
the only one works is
oWB.Sheets.Add
but it works like adding sheet to the beginning of the sheets list
am i doing something wrong?
i would appreciate your help
oXL = CreateObject("Excel.Application") oWB = oXL.Workbooks.Add [color=red]oWB.Sheets.Add After:=oWB.Sheets(oWB.Sheets.Count)[/color]i'm trying following and all this gives me error:
oWB.Sheets.Add("",oWB.Sheets(oWB.Sheets.Count))
oWB.Sheets.Add(0,oWB.Sheets(oWB.Sheets.Count))
oWB.Sheets.Add("After",oWB.Sheets(oWB.Sheets.Count))
<!-- m -->http://msdn.microsof...ry ... 12).aspx<!-- m -->
the only one works is
oWB.Sheets.Add
but it works like adding sheet to the beginning of the sheets list
am i doing something wrong?
i would appreciate your help
#125
-
Posted 01 April 2011 - 11:39 PM
![COM Object Reference [AutoHotkey v1.1+]: post #125](http://autohotkey.com/board/public/style_images/ortem/icon_share.png)
Named parameters aren't supported yet.
expression.Add(Before, After, Count, Type)
Source: Add Method [Excel 2007 Developer Reference]
oWB.Sheets.Add(ComObjMissing(), oWB.Sheets(oWB.Sheets.Count))Untested. ComObjMissing() indicates the parameter should be entirely omitted.
#126
-
Posted 01 April 2011 - 11:48 PM
![COM Object Reference [AutoHotkey v1.1+]: post #126](http://autohotkey.com/board/public/style_images/ortem/icon_share.png)
it works
thank you!
wonder how did i miss this in the help...
thank you!
wonder how did i miss this in the help...
#127
-
Posted 01 April 2011 - 11:56 PM
![COM Object Reference [AutoHotkey v1.1+]: post #127](http://autohotkey.com/board/public/style_images/ortem/icon_share.png)
get SAP GUI controls
I tried with AHK_L (under winXP) to get SAP GUI controls,
with the mouse over coordiantes, but AHK_L could 'see' any control
means:
could not see the Control ID and could not see it's TEXT value
is there any tool in AHK that I can override this problem ?
I saw in internet, that with autoit, in some way, it can be achieved.
so why not with AHK_L ?
JAVA Forms
same problem I got with JAVA Forms( in winXP), that does not see any control, do I need another tool for that ?
any help will be appreciated
rgrds
rani
I tried with AHK_L (under winXP) to get SAP GUI controls,
with the mouse over coordiantes, but AHK_L could 'see' any control
means:
could not see the Control ID and could not see it's TEXT value
is there any tool in AHK that I can override this problem ?
I saw in internet, that with autoit, in some way, it can be achieved.
so why not with AHK_L ?
JAVA Forms
same problem I got with JAVA Forms( in winXP), that does not see any control, do I need another tool for that ?
any help will be appreciated
rgrds
rani
#128
-
Posted 02 April 2011 - 04:55 PM
![COM Object Reference [AutoHotkey v1.1+]: post #128](http://autohotkey.com/board/public/style_images/ortem/icon_share.png)
hey, guys
how can i pass an array as parameter if function needs it?
for example here is a code:
how can i pass an array as parameter if function needs it?
for example here is a code:
oExcel := ComObjCreate("Excel.Application") ; create Excel Application object oWB := oExcel.Workbooks.Add ; create a new workbook oExcel.Visible := 1 sFileName := "C:\SomeDelimetedFile.txt" oSheet := oWB.Sheets[1] oQT := oSheet.QueryTables.Add("TEXT;" . sFileName,oSheet.Range("$A$1")) [color=red]oQT.TextFileColumnDataTypes := Array(1)[/color] ;http://msdn.microsoft.com/en-us/library/aa215749%28v=office.11%29.aspxit says "incorrect parameter" when i try to do it as in example
#129
-
Posted 04 April 2011 - 12:05 PM
![COM Object Reference [AutoHotkey v1.1+]: post #129](http://autohotkey.com/board/public/style_images/ortem/icon_share.png)
Since your array only has one element, you might be able to just use the number:
oQT.TextFileColumnDataTypes := 1... otherwise, you would create a Com Ojbect Array (SafeArray):
Array := ComObjArray(3,1) Array[0] := 1 oQT.TextFileColumnDataTypes := Array
#130
-
Posted 04 April 2011 - 01:30 PM
![COM Object Reference [AutoHotkey v1.1+]: post #130](http://autohotkey.com/board/public/style_images/ortem/icon_share.png)
A post with examples of how to create a SafeArray is located here in this thread.
#131
-
Posted 04 April 2011 - 01:32 PM
![COM Object Reference [AutoHotkey v1.1+]: post #131](http://autohotkey.com/board/public/style_images/ortem/icon_share.png)
[*:3e7udvi6]COM Object: CAPICOM Series
[*:3e7udvi6]Purpose: digitally sign data, sign code, verify digital signatures, envelop data for privacy, hash data, encrypt/decrypt data and more.
[*:3e7udvi6]System Requirements: 32-bit OS, for more details, please see MSDN
[*:3e7udvi6]Documentation Link: CAPICOM Reference
[*:3e7udvi6]Other Links:Platform SDK Redistributable: CAPICOM
[*:3e7udvi6]Basic Code Example: First require to install capicom.dll from microsoft's site above.
/* ************************************************************ CAPIEncrypt.ahk This is a sample script to illustrate how to use the CAPICOMs EncryptedData to encrypt/decrypt text file. Note: For simplicity, this script does not handle exception. ************************************************************ */ ForReading := 1 ForWriting := 2 ; CAPICOM's constants. CAPICOM_ENCRYPTION_ALGORITHM_RC2 := 0 CAPICOM_ENCRYPTION_ALGORITHM_RC4 := 1 CAPICOM_ENCRYPTION_ALGORITHM_DES := 2 CAPICOM_ENCRYPTION_ALGORITHM_3DES := 3 CAPICOM_ENCRYPTION_ALGORITHM_AES := 4 CAPICOM_ENCRYPTION_KEY_LENGTH_MAXIMUM := 0 CAPICOM_ENCRYPTION_KEY_LENGTH_40_BITS := 1 CAPICOM_ENCRYPTION_KEY_LENGTH_56_BITS := 2 CAPICOM_ENCRYPTION_KEY_LENGTH_128_BITS := 3 CAPICOM_ENCRYPTION_KEY_LENGTH_192_BITS := 4 CAPICOM_ENCRYPTION_KEY_LENGTH_256_BITS := 5 strSF := "C:\test.txt" strOF := "C:\Encrypted.txt" Algorithm := CAPICOM_ENCRYPTION_ALGORITHM_AES KeyLength := CAPICOM_ENCRYPTION_KEY_LENGTH_56_BITS Password := "123456" EncryptCommand(strSF, strOF, Algorithm, KeyLength, Password) ;~ DecryptCommand(strSF, strOF, Password) return ; End Main ; EncryptCommand() - Encrypt content of text file ObjectFile. EncryptCommand(SourceFile, ObjectFile, Algorithm, KeyLength, Password) { Content := "" Message := "" EncryptedData := "" ; Create the EncryptedData object. EncryptedData := ComObjCreate("CAPICOM.EncryptedData") ; algorithm, key size, and encryption password. EncryptedData.Algorithm.Name := Algorithm EncryptedData.Algorithm.KeyLength := KeyLength EncryptedData.SetSecret(Password) ; Display main title. MsgBox, % "Encrypting text file " . SourceFile . "." ; Load content of text file to be encrypted. LoadFile(SourceFile, Content) ; Now encrypt it. EncryptedData.Content := Content Message := EncryptedData.Encrypt ; Finally, save encrypted message to strSF. SaveFile(ObjectFile, Message) MsgBox, % "Successful - Encrypted message saved to " . ObjectFile . "." ; Free resources. EncryptedData := "" } ; DecryptCommand() - Decrypt an encrypted file. DecryptCommand(SourceFile, ObjectFile, Password) { Message := "" EncryptedData := "" ; Create the EncryptedData object. EncryptedData := ComObjCreate("CAPICOM.EncryptedData") ; decryption password. EncryptedData.SetSecret(Password) ; Display main title. MsgBox, % "Decrypting encrypted text file " . SourceFile . "." ; Load the encrypted message. LoadFile(SourceFile, Message) ; Now decrypt it. EncryptedData.Decrypt(Message) ; Finally, save decrypted content to strSF. SaveFile(ObjectFile, EncryptedData.Content) MsgBox, % "Successful - Decrypted content saved to " . ObjectFile . "." ; Free resources. EncryptedData := "" } ; LoadFile() - Read content of a text file. LoadFile(FileName, ByRef Buffer) { global ForReading objFSO := "", objTS := "" objFSO := ComObjCreate("Scripting.FileSystemObject") If Not objFSO.FileExists(FileName) { MsgBox, % "Error: File " . FileName . " not found." ExitApp } objTS := objFSO.OpenTextFile(FileName, ForReading) Buffer := objTS.ReadAll } ; SaveFile() - Save string to file. SaveFile(FileName, ByRef Buffer) { global ForWriting objFSO := "", objTS := "" objFSO := ComObjCreate("Scripting.FileSystemObject") objTS := objFSO.OpenTextFile(FileName, ForWriting, True) objTS.Write(Buffer) } return
#133
-
Posted 06 April 2011 - 10:28 AM
![COM Object Reference [AutoHotkey v1.1+]: post #133](http://autohotkey.com/board/public/style_images/ortem/icon_share.png)
I am interested in implementing AHK_L but need to migrate some of my code accordingly.
I use a variant of the first post on ADO COM - Database Query. Can someone convert it to AHK_L?
I also need code to read a file from inside an SQL database (I know how to connect to it and can read from it currently using the code above), and then write the file out - basically an export.
Cany anyone help me?[/url]
I use a variant of the first post on ADO COM - Database Query. Can someone convert it to AHK_L?
I also need code to read a file from inside an SQL database (I know how to connect to it and can read from it currently using the code above), and then write the file out - basically an export.
Cany anyone help me?[/url]
#134
-
Posted 07 April 2011 - 10:14 PM
![COM Object Reference [AutoHotkey v1.1+]: post #134](http://autohotkey.com/board/public/style_images/ortem/icon_share.png)
SilverEdge78
I can't test it, as I don't have a database to test on.
sSource := "SELECT * FROM " . "atlas" ; . " WHERE country LIKE 'A%'" sConnect := "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" . "C:\Database\atlas.mdb" prs := ComObjCreate("ADODB.Recordset") prs.Open(sSource, sConnect) While !prs.EOF { pFields := prs.Fields Loop, % pFields.Count pField:= pFields.Item(A_Index-1) , sData .= pField.Name . ": " . pField.Value . "`r`n" prs.MoveNext() } prs.Close() MsgBox, % sDataIf you get an error, press Control-C in the Msgbox and post it here. Of course if the prs.Open line gives you an error, the first two lines are wrong and I can't help you with that.
#135
-
Posted 07 April 2011 - 11:14 PM
![COM Object Reference [AutoHotkey v1.1+]: post #135](http://autohotkey.com/board/public/style_images/ortem/icon_share.png)
aboutscript ⋰ apps ⋱ scripts
Request Video Tutorials Here or View Current Tutorials on YouTube
Any code ⇈ above ⇈ requires AutoHotkey_L to run
Request Video Tutorials Here or View Current Tutorials on YouTube
Any code ⇈ above ⇈ requires AutoHotkey_L to run