Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 01/14/2014 in all areas

  1. Take it from me. I started using AutoIt about 6 months ago. The only thing I knew was a little QB and VB from college 10 years ago. I dabbled with the example scripts and looked through the forums here. I even drew out on paper what I wanted one of my scripts to do. Now I have one script that was approved for use here at work and I am working on another. They are nothing huge and extraordinary, but it is better than what we had before it went live. Read, read, read and give it a try. I did a lot of learning from making mistakes with the code. Don't be afraid to ask questions. I have asked some (what I thought was really stupid) questions here and I have gotten nothing but loads of help.
    2 points
  2. Run a process and surpress any windows created by that process that may become visible. Main purpose is to automate gui-applications on a hidden desktop so that the user cannot disturb the process. Its my first attempt to write a UDF so please be patient. Advices, bug reports and recommendations are welcome. . #Include <WinAPIEx.au3> ; #FUNCTION# ==================================================================================================================== ; Name ..........: ShellExecuteHidden ; ; Description ...: runs a process on another winApi-desktop, so that none of its windows ever get visible, but can be automated by window messages and other technologies. ; The difference to shellExecute( ... , ... , @SW_HIDE ) is, that no just the first, but any windows from the created process will stay totaly isolated from user input and graphics ; ; Syntax ........: ShellExecuteHidden($filepath[, $parameters = "" [, $returnType = 1 [, $waitingOption = -1 ]]]) ; ; Parameters ....: $filepath - the file to run ; ; $returnType = 0 >> returns window handle of toplevel window of the started process ; even if its window is "hidden" (would not be visible on normal desktop) ; = 1 >> returns window handle of toplevel window of the started process ; = 2 >> returns process id (PID) of the started process ; ; ; $waitingOption = -2 >> dont wait (not recommended for window handles, as they need some time to appear even if the program is loading fast) ; = -1 >> wait 1000 milliseconds for windows to "appear" but dont wait for processes to finish (compromise) ; = 0 >> wait for the process to finish or the window to appear ; = <x> >> wait <x> milliseconds for the process to finish or the window to appear (see "$returnType" ) ; ; Return values .: windowHandle or ProcessID ; Author ........: Bluesmaster ; Modified ......: 2013 - 11 - 09 ; Remarks .......: ; Related .......: ShellExecute, _WinAPI_CreateDesktop ; Link ..........: http://msdn.microsoft.com/en-us/library/windows/desktop/ms687098(v=vs.85).aspx ; Example .......: Yes ; =============================================================================================================================== Func _shellExecuteHidden( $filepath , $parameters = "" , $returnType = 1 , $waitingOption = -1 ) ; 1 - Create Desktop ;Global Const $GENERIC_ALL = 0x10000000 $hNewDesktop = _WinAPI_CreateDesktop( "ShellExecuteHidden_Desktop" , $GENERIC_ALL ) ; 2 - Start Process $tProcess = DllStructCreate( $tagPROCESS_INFORMATION ) $tStartup = DllStructCreate( $tagSTARTUPINFO ) DllStructSetData( $tStartup , 'Size', DllStructGetSize( $tStartup) ) DllStructSetData( $tStartup , 'Desktop', _WinAPI_CreateString( "ShellExecuteHidden_Desktop" ) ) Local $pid If _WinAPI_CreateProcess( $filepath , $parameters , 0, 0, 0, 0x00000200 , 0, 0, DllStructGetPtr($tStartup), DllStructGetPtr($tProcess)) Then $pid = DllStructGetData( $tProcess , 'ProcessID' ) Else Return -1 EndIf ; 3 - Return Process if $returnType = 2 Then if $waitingOption > -1 Then ProcessWaitClose( $pid , $waitingOption ) Return $pid EndIf ; 4 - Return WindowHandle if $waitingOption = -1 Then Sleep( 1000 ) ElseIf $waitingOption > 0 Then Sleep( $waitingOption ) EndIf While True ; keep searching for the window $aWindows = _WinAPI_EnumDesktopWindows( $hNewDesktop , $returnType ) ; $returnType = 0 >> means also list hidden windows if IsArray( $aWindows ) Then for $i = 1 to $aWindows[0][0] ;~ MsgBox( 0 , '' , $curPID & " " & $pid & " " & $hWnd & " " & $aWindows[$i][0] ) $hWnd = $aWindows[$i][0] if $pid = WinGetProcess( $hWnd ) Then ; same process? do ; searching through parent windows ... $hLast = $hWnd ; cache it for not loosing it when desktop is reached $hWnd = _WinAPI_GetParent( $hLast ) Until $hWnd = 0 ; ... until root/ desktop is reached $hWnd = $hLast Return $hWnd ; return the toplevel-window of the process EndIf Next EndIf if $waitingOption = 0 Then ; keep searching for the window until it appears ( in worst case endless ) Sleep( 200 ) Else Return -1 EndIf WEnd EndFunc . Examples: (also included as comment in download file) ; EXAMPLE 1 ( principle ): ; 1 - open a programm with @SW_HIDE ShellExecute( @ComSpec , "/c start notepad.exe" , "" , "" , @SW_HIDE ) WinWaitActive( "[CLASS:Notepad]" ) ControlSend( "[CLASS:Notepad]" , "" , "Edit1" , "As you can see, you cannot prevent an hidden started application " & @LF & "from opening another window that gets visible...") MsgBox( 0 , '' , "I understand. show me the version with appstart on hidden desktop" ) WinKill( "[CLASS:Notepad]" ) ; 2 - do the same routine with "_shellExecuteHidden" $hWinHiddenApp = _shellExecuteHidden( @ComSpec , "/c start notepad.exe" ) ShellExecute( "taskmgr.exe" ) MsgBox( 0 , '' , "...´ok look in your taskmanager now. There should be a new notepad.exe entry but no window is visible." ) ; 3 - close hidden application WinKill( $hWinHiddenApp ) ; EXAMPLE 2 ( interaction ): ; 1 - start hidden application MsgBox( 0 , '' , "Now we start an editor on the hidden desktop and interact with it programmaticly" ) $hWinHiddenApp = _shellExecuteHidden( @SystemDir & "\notepad.exe" ) ; 2 - send to hidden application ControlSend( $hWinHiddenApp , "" , "Edit1" , "di{BS}eb{BS}mk{BS}os{BS}" ) ; 3 - receive information from hidden application MsgBox( 0 , '' , "Text in the editor on hidden desktop: " & @LF & @LF & ControlGetText( $hWinHiddenApp , "" , "Edit1" ) ) ; 4 - close hidden application WinKill( $hWinHiddenApp ) . _shellExecuteHidden.au3 winapiex (needed)
    1 point
  3. wolf9228

    Other Interface call

    First Interface call '?do=embed' frameborder='0' data-embedContent>> By the project you can call methods of classes And Interface through DispCallFunc function I think the project is important for all ... Thanks All project files Other_InterfaceCall.zip InterfaceCall.au3 ;enum $tagCALLCONV Global $CC_FASTCALL = 0 Global $CC_CDECL = 1 Global $CC_MSCPASCAL = $CC_CDECL + 1 Global $CC_PASCAL = $CC_MSCPASCAL Global $CC_MACPASCAL = $CC_PASCAL + 1 Global $CC_STDCALL = $CC_MACPASCAL + 1 Global $CC_FPFASTCALL = $CC_STDCALL + 1 Global $CC_SYSCALL = $CC_FPFASTCALL + 1 Global $CC_MPWCDECL = $CC_SYSCALL + 1 Global $CC_MPWPASCAL = $CC_MPWCDECL + 1 Global $CC_MAX = $CC_MPWPASCAL + 1 ;enum $tagCALLCONV Global $OleAut32 = DllOpen("OleAut32.dll") Global $tagVariant = "USHORT vt;WORD wReserved1;WORD wReserved2;WORD wReserved3;byte union[8]" Global $SizeOfUlong_Ptr = DllStructGetSize(DllStructCreate("ULONG_PTR")) Func InterfaceCall($Inface,$ReturnType,$MethodNum,$Type1 = 0,$Param1 = 0,$Type2 = 0,$Param2 = 0 _ ,$Type3 = 0,$Param3 = 0, $Type4 = 0,$Param4 = 0 ,$Type5 = 0 ,$Param5 = 0,$Type6 = 0,$Param6 = 0 _ ,$Type7 = 0,$Param7 = 0, $Type8 = 0,$Param8 = 0,$Type9 = 0,$Param9 = 0,$Type10 = 0,$Param10 = 0 _ ,$Type11= 0,$Param11= 0,$Type12= 0,$Param12= 0,$Type13= 0,$Param13 = 0,$Type14 = 0,$Param14 = 0 _ ,$Type15= 0,$Param15= 0,$Type16= 0,$Param16= 0,$Type17= 0,$Param17 = 0,$Type18 = 0,$Param18 = 0 _ ,$Type19= 0,$Param19= 0,$Type20= 0,$Param20= 0,$Type21= 0,$Param21 = 0,$Type22 = 0,$Param22 = 0 _ ,$Type23= 0,$Param23= 0,$Type24= 0,$Param24= 0,$Type25= 0,$Param25 = 0,$Type26 = 0,$Param26 = 0 _ ,$Type27= 0,$Param27= 0,$Type28= 0,$Param28= 0,$Type29= 0,$Param29 = 0,$Type30 = 0,$Param30 = 0) ;Call Only Virtual Methods Form any Class Or From any Interface ;$MethodNum ==> Virtual Method Number In (Virtual Methods Table) ;See the examples ;-------------------------------------------------------------------;C++ Example1 ;C++ Example1 ;class iClass ;{ ;public: ;void MethodA() ;{ ;MessageBox(0,"MethodA","MSG",0); ;} ;virtual void VirtualMethodB() ;{ ;MessageBox(0,"VirtualMethodB","MSG",0); ;} ;virtual void VirtualMethodC() ;{ ;MessageBox(0,"VirtualMethodC","MSG",0); ;} ;void MethodB() ;{ ;MessageBox(0,"MethodB","MSG",0); ;} ;virtual void VirtualMethodA() ;{ ;MessageBox(0,"VirtualMethodA","MSG",0); ;} ;}; ;-----------------------------------------------------------;Virtual Methods Table ;Virtual Methods Table ;virtual void VirtualMethodB() ==> Virtual Method Number Is 1 ;virtual void VirtualMethodC() ==> Virtual Method Number Is 2 ;virtual void VirtualMethodA() ==> Virtual Method Number Is 3 ;-----------------------------------------------------------;Virtual Methods Table ;-------------------------------------------------------------------;C++ Example1 ;//////////////////////////////////////////////////////////////////////////////// ;-------------------------------------------------------------------;C++ Example2 ;C++ Example2 ;class iClassA ;{ ;public: ;void MethodA() ;{ ;MessageBox(0,"MethodA","MSG",0); ;} ;virtual void VirtualMethodB() ;{ ;MessageBox(0,"VirtualMethodB","MSG",0); ;} ;virtual void VirtualMethodC() ;{ ;MessageBox(0,"VirtualMethodC","MSG",0); ;} ;}; ;class iClassB : public iClassA ;{ ;public: ;void MethodD() ;{ ;MessageBox(0,"MethodD","MSG",0); ;} ;virtual void VirtualMethodF() ;{ ;MessageBox(0,"VirtualMethodF","MSG",0); ;} ;virtual void VirtualMethodE() ;{ ;MessageBox(0,"VirtualMethodE","MSG",0); ;} ;}; ;//////////////////////////////////////////////////////////////////////////////// ;//////////////////////////////////////////////////////////////////////////////// ;------------------------------------------;Virtual Methods Table Of iClassA Class ;Virtual Methods Table Of iClassA Class ;virtual void VirtualMethodB() ==> Virtual Method Number Is 1 ;virtual void VirtualMethodC() ==> Virtual Method Number Is 2 ;------------------------------------------;Virtual Methods Table Of iClassA Class ;//////////////////////////////////////////////////////////////////////////////// ;/////////////////////////////////////////////////////////////////////////////// ;------------------------------------------;Virtual Methods Table Of iClassB Class ;class iClassB : public iClassA ;base class ==> iClassA ;derived class ==> iClassB ;http://msdn.microsoft.com/en-us/library/hzk8a7d3.aspx ;When preceding the name of a base class, the public keyword specifies that the public ;and protected members of the base class are public and protected members, respectively, ;of the derived class. ;------------------------------------------------------------------------------------- ;Virtual Methods Table Of iClassB Class ;virtual void VirtualMethodB() In (iClassA) ==> Virtual Method Number Is 1 ;virtual void VirtualMethodC() In (iClassA) ==> Virtual Method Number Is 2 ;virtual void VirtualMethodF() In (iClassB) ==> Virtual Method Number Is 3 ;virtual void VirtualMethodE() In (iClassB) ==> Virtual Method Number Is 4 ;------------------------------------------;Virtual Methods Table Of iClassB Class ;-------------------------------------------------------------------;C++ Example2 ;//////////////////////////////////////////////////////////////////////////////// if ((@NumParams > 3) And (Mod((@NumParams - 3),2) <> 0)) Then Return SetError(1,0,0) Local $NumParams = ((@NumParams - 3) / 2) Local $nReturn[$NumParams + 1][3], $Variant = 0,$BOOLREF = 0,$RtVariant = 0 Local $Value = "",$DataType = "",$DataTypeNu = 0,$RtTypeNu = 0,$CALLCONV = $CC_STDCALL Local $VARIANTARG = DllStructCreate("PTR[" & $NumParams & "]") Local $VARTYPE = DllStructCreate("WORD[" & $NumParams & "]") $ReturnType = StringUpper($ReturnType) if (StringRight($ReturnType,6) == ";CDECL") Then $ReturnType = StringReplace($ReturnType,";CDECL","") $CALLCONV = $CC_CDECL EndIf For $i = 0 To $NumParams if ($i = 0) Then ; $i = 0 Is Return $DataType = $ReturnType $Value = "" $DataTypeNu = InfaceDataTypeNu($DataType) if @error Then Return SetError(2,0,0) $BOOLREF = @extended $RtTypeNu = $DataTypeNu $Variant = DllStructCreate($tagVariant) $RtVariant = $Variant $nReturn[$i][0] = $Variant DllStructSetData($Variant,"vt",$DataTypeNu) $DataType = StringReplace($DataType,"*","") Else $Value = Eval("Param" & $i) $DataType = Eval("Type" & $i) $DataTypeNu = InfaceDataTypeNu($DataType) if @error Then Return SetError(2,0,0) $BOOLREF = @extended $Variant = DllStructCreate($tagVariant) $nReturn[$i][0] = $Variant DllStructSetData($Variant,"vt",$DataTypeNu) DllStructSetData($VARTYPE,1,$DataTypeNu,$i) DllStructSetData($VARIANTARG,1,DllStructGetPtr($Variant),$i) EndIf $DataType = StringReplace(StringUpper($DataType),"*","") Switch $DataType Case "STR" if ($i = 0) Then $BOOLREF = True ; $i = 0 Is Return Switch $BOOLREF Case True $nReturn[$i][1] = MakByRef() $nReturn[$i][2] = 3 SetUnionOfVariant($Variant,"ptr",DllStructGetPtr($nReturn[$i][1])) Case False $StringSt = DllStructCreate("CHAR[" & (StringLen($Value) + 1) & "]") DllStructSetData($StringSt,1,$Value) $nReturn[$i][1] = $StringSt $nReturn[$i][2] = 2 SetUnionOfVariant($Variant,"ptr",DllStructGetPtr($StringSt)) EndSwitch Case "WSTR" if ($i = 0) Then $BOOLREF = True ; $i = 0 Is Return Switch $BOOLREF Case True $nReturn[$i][1] = MakByRef() $nReturn[$i][2] = 4 SetUnionOfVariant($Variant,"ptr",DllStructGetPtr($nReturn[$i][1])) Case False $StringSt = DllStructCreate("WCHAR[" & (StringLen($Value) + 1) & "]") DllStructSetData($StringSt,1,$Value) $nReturn[$i][1] = $StringSt $nReturn[$i][2] = 2 SetUnionOfVariant($Variant,"ptr",DllStructGetPtr($StringSt)) EndSwitch Case "STRUCT" $nReturn[$i][1] = $Value SetUnionOfVariant($Variant,"ptr",DllStructGetPtr($Value)) $nReturn[$i][2] = 0 Case Else Switch $BOOLREF Case True $nReturn[$i][1] = MakByRef($DataType) $nReturn[$i][2] = 1 SetUnionOfVariant($Variant,"ptr",DllStructGetPtr($nReturn[$i][1])) Case False $nReturn[$i][1] = $Value $nReturn[$i][2] = 0 SetUnionOfVariant($Variant,$DataType,$Value) EndSwitch EndSwitch Next Local $oVft = ($SizeOfUlong_Ptr * ($MethodNum - 1));$MethodNum ==> Virtual Method Number In Virtual Methods Table Start From 1 $HRESULT = DllCall($OleAut32,"long","DispCallFunc","ptr",$Inface,"ULONG_PTR",$oVft,"int",$CALLCONV _ ,"WORD",$RtTypeNu,"UINT",$NumParams,"struct*",$VARTYPE,"struct*",$VARIANTARG ,"struct*",$RtVariant) if @error Or $HRESULT[0] <> 0 Then Return SetError(3,0,0) Local $vReturn[($NumParams + 1)] For $i = 0 To $NumParams $Value = $nReturn[$i][1] $IsOutDllStruct = $nReturn[$i][2] if ($i = 0) Then ; $i = 0 Is Return Switch $IsOutDllStruct Case 0 ;WtheOut ByRef $vReturn[$i] = GetUnionOfVariant($RtVariant,$ReturnType) Case 1 ;Wthe ByRef $vReturn[$i] = GetByRefValue($Value) Case 3 ;Wthe ByRef Ans String Data Type $vReturn[$i] = StringFromPtr(GetByRefValue($Value),False) Case 4 ;Wthe ByRef UniCode String Data Type $vReturn[$i] = StringFromPtr(GetByRefValue($Value),True) EndSwitch Else ; Else Params Switch $IsOutDllStruct Case 0 ;WtheOut ByRef $vReturn[$i] = $Value Case 1 ;Wthe ByRef $vReturn[$i] = GetByRefValue($Value) Case 2 ;WtheOut ByRef Ans Or UniCode String Data Type $vReturn[$i] = DllStructGetData($Value,1) ;Get String From $StringSt Case 3 ;Wthe ByRef Ans String Data Type $vReturn[$i] = StringFromPtr(GetByRefValue($Value),False) Case 4 ;Wthe ByRef UniCode String Data Type $vReturn[$i] = StringFromPtr(GetByRefValue($Value),True) EndSwitch EndIf Next Return $vReturn EndFunc Func StringFromPtr($StringPtr,$UniCode = False) if (Not(IsPtr($StringPtr)) Or $StringPtr = Ptr(0)) Then Return SetError(1,0,"") if ($UniCode) Then $StrLen = DllCall("Kernel32.dll","int","lstrlenW","ptr",$StringPtr) if @error Then Return SetError(2,0,"") $StrLen = $StrLen[0] Return DllStructGetData(DllStructCreate("WCHAR[" & ($StrLen + 1) & "]",$StringPtr),1) Else $StrLen = DllCall("Kernel32.dll","int","lstrlenA","ptr",$StringPtr) if @error Then Return SetError(2,0,"") $StrLen = $StrLen[0] Return DllStructGetData(DllStructCreate("CHAR[" & ($StrLen + 1) & "]",$StringPtr),1) EndIf EndFunc Func InfaceDataTypeNu($DataType) ;VARIANT structure ;http://msdn.microsoft.com/en-us/library/windows/desktop/ms221627%28v=vs.85%29.aspx ;VARENUM enumeration ;http://msdn.microsoft.com/en-us/library/windows/desktop/ms221170%28v=vs.85%29.aspx Local $DataTypeNu , $VT_BYREF = 0x4000 $DataType = StringUpper($DataType) Switch $DataType Case "STRUCT*","STR","WSTR" $DataType = "PTR" Case "STR*","WSTR*" $DataType = "PTR*" EndSwitch Local $BOOLREF = (StringInStr($DataType,"*") <> 0) $DataType = StringReplace($DataType,"*","") Switch $DataType Case "NONE" $DataTypeNu = 24 Case "BYTE","BOOLEAN" $DataTypeNu = 17 Case "SHORT" $DataTypeNu = 2 Case "USHORT","WORD" $DataTypeNu = 18 Case "INT","LONG","BOOL" $DataTypeNu = 22 Case "UINT","ULONG","DWORD" $DataTypeNu = 23 Case "INT64" $DataTypeNu = 20 Case "UINT64" $DataTypeNu = 21 Case "FLOAT" $DataTypeNu = 4 Case "DOUBLE" $DataTypeNu = 5 ;--------------------------------------------------------------------------------------------- ;_____________ C++ 6.0 wtypes.h __________ ;VT_I8 = 20 ;VT_UI8 = 21 ;VT_I4 = 3 ;VT_UI4 = 19 ;#ifdef _WIN64 ;#define VT_INT_PTR VT_I8 ;#define VT_UINT_PTR VT_UI8 ;#else ;#define VT_INT_PTR VT_I4 ;#define VT_UINT_PTR VT_UI4 ;#endif ;_____________ C++ 6.0 wtypes.h __________ ; _WIN64 Macro Defined for applications for Win64. ;@AutoItX64 Returns 1 if the script is running under the native x64 version of AutoIt. Case "HWND" ;32bit(4bytes) integer $DataTypeNu = 3 ;VT_I4 Case "HANDLE" ;32bit(4bytes) integer $DataTypeNu = 3 ;VT_I4 Case "LPARAM","INT_PTR","LONG_PTR","LRESULT" ;32 or 64bit signed integer if (@AutoItX64) Then $DataTypeNu = 20 ;VT_I8 Else $DataTypeNu = 3 ;VT_I4 EndIf Case "PTR","UINT_PTR","ULONG_PTR","DWORD_PTR","WPARAM" ;32 or 64bit unsigned integer if (@AutoItX64) Then $DataTypeNu = 21 ;VT_UI8 Else $DataTypeNu = 19 ;VT_UI4 EndIf ;_____________ C++ 6.0 wtypes.h __________ ;VT_I8 = 20 ;VT_UI8 = 21 ;VT_I4 = 3 ;VT_UI4 = 19 ;#ifdef _WIN64 ;#define VT_INT_PTR VT_I8 ;#define VT_UINT_PTR VT_UI8 ;#else ;#define VT_INT_PTR VT_I4 ;#define VT_UINT_PTR VT_UI4 ;#endif ;_____________ C++ 6.0 wtypes.h __________ ; _WIN64 Macro Defined for applications for Win64. ;@AutoItX64 Returns 1 if the script is running under the native x64 version of AutoIt ;--------------------------------------------------------------------------------------------- Case Else Return SetError(1,0,-1) EndSwitch if ($BOOLREF) Then $DataTypeNu = BitOR($VT_BYREF,$DataTypeNu) Return SetError(0,$BOOLREF,$DataTypeNu) EndFunc Func MakByRef($DataType = "ptr") Return DllStructCreate(String($DataType & " ByRef")) EndFunc Func GetByRefValue($ByRefSt) Return DllStructGetData($ByRefSt,1) EndFunc Func SetUnionOfVariant($VariantSt,$DataType,$Value) Return DllStructSetData(DllStructCreate($DataType,DllStructGetPtr($VariantSt,"union")),1,$Value) EndFunc Func GetUnionOfVariant($VariantSt,$DataType) Return DllStructGetData(DllStructCreate($DataType,DllStructGetPtr($VariantSt,"union")),1) EndFunc Func CLSIDFromString($psz) $GUID = DllStructCreate("ulong Data1;ushort Data2;ushort Data3;byte Data4[8]") $Oleerror = DllCall("Ole32.dll","int","CLSIDFromString","WSTR",$psz,"struct*",$GUID) if @error Or $Oleerror[0] <> 0 Then Return SetError(1,0,0) Return SetError(0,0,$Oleerror[2]) EndFunc Func IIDFromString($psz) $GUID = DllStructCreate("ulong Data1;ushort Data2;ushort Data3;byte Data4[8]") $Oleerror = DllCall("Ole32.dll","int","IIDFromString","WSTR",$psz,"struct*",$GUID) if @error Or $Oleerror[0] <> 0 Then Return SetError(1,0,0) Return SetError(0,0,$Oleerror[2]) EndFunc IPictureInterface.au3 #include "InterfaceCall.au3" #include <WinAPI.au3> ;IPicture interface---------------------------------------------------------;IPicture interface ;EXTERN_C const IID IID_IPicture; ; ; ; ;#if defined(__cplusplus) && !defined(CINTERFACE) ; ; ; ; MIDL_INTERFACE("7BF80980-BF32-101A-8BBB-00AA00300CAB") ; ; IPicture : public IUnknown ; ; { ; ; public: ; ; virtual HRESULT STDMETHODCALLTYPE get_Handle( ; ; /* [out] */ OLE_HANDLE __RPC_FAR *pHandle) = 0; ; ; ; ; virtual HRESULT STDMETHODCALLTYPE get_hPal( ; ; /* [out] */ OLE_HANDLE __RPC_FAR *phPal) = 0; ; ; ; ; virtual HRESULT STDMETHODCALLTYPE get_Type( ; ; /* [out] */ SHORT __RPC_FAR *pType) = 0; ; ; ; ; virtual HRESULT STDMETHODCALLTYPE get_Width( ; ; /* [out] */ OLE_XSIZE_HIMETRIC __RPC_FAR *pWidth) = 0; ; ; ; ; virtual HRESULT STDMETHODCALLTYPE get_Height( ; ; /* [out] */ OLE_YSIZE_HIMETRIC __RPC_FAR *pHeight) = 0; ; ; ; ; virtual HRESULT STDMETHODCALLTYPE Render( ; ; /* [in] */ HDC hDC, ; ; /* [in] */ LONG x, ; ; /* [in] */ LONG y, ; ; /* [in] */ LONG cx, ; ; /* [in] */ LONG cy, ; ; /* [in] */ OLE_XPOS_HIMETRIC xSrc, ; ; /* [in] */ OLE_YPOS_HIMETRIC ySrc, ; ; /* [in] */ OLE_XSIZE_HIMETRIC cxSrc, ; ; /* [in] */ OLE_YSIZE_HIMETRIC cySrc, ; ; /* [in] */ LPCRECT pRcWBounds) = 0; ; ; ; ; virtual HRESULT STDMETHODCALLTYPE set_hPal( ; ; /* [in] */ OLE_HANDLE hPal) = 0; ; ; ; ; virtual HRESULT STDMETHODCALLTYPE get_CurDC( ; ; /* [out] */ HDC __RPC_FAR *phDC) = 0; ; ; ; ; virtual HRESULT STDMETHODCALLTYPE SelectPicture( ; ; /* [in] */ HDC hDCIn, ; ; /* [out] */ HDC __RPC_FAR *phDCOut, ; ; /* [out] */ OLE_HANDLE __RPC_FAR *phBmpOut) = 0; ; ; ; ; virtual HRESULT STDMETHODCALLTYPE get_KeepOriginalFormat( ; ; /* [out] */ BOOL __RPC_FAR *pKeep) = 0; ; ; ; ; virtual HRESULT STDMETHODCALLTYPE put_KeepOriginalFormat( ; ; /* [in] */ BOOL keep) = 0; ; ; ; ; virtual HRESULT STDMETHODCALLTYPE PictureChanged( void) = 0; ; ; ; ; virtual HRESULT STDMETHODCALLTYPE SaveAsFile( ; ; /* [in] */ LPSTREAM pStream, ; ; /* [in] */ BOOL fSaveMemCopy, ; ; /* [out] */ LONG __RPC_FAR *pCbSize) = 0; ; ; ; ; virtual HRESULT STDMETHODCALLTYPE get_Attributes( ; ; /* [out] */ DWORD __RPC_FAR *pDwAttr) = 0; ; ; ; ; }; ;IPicture interface---------------------------------------------------------;IPicture interface ;------------------------------- ;IPicture : public IUnknown ;-------------------------------- ;base class ==> IUnknown ;derived class ==> IPicture ;--------------------------------- ;http://msdn.microsoft.com/en-us/library/hzk8a7d3.aspx ;When preceding the name of a base class, the public keyword specifies that the public ;and protected members of the base class are public and protected members, respectively, ;of the derived class. ;--------------------------------- ;IUnknown interface---------------------------------------------------------;IUnknown interface ;#if (_MSC_VER >= 1100) && defined(__cplusplus) && !defined(CINTERFACE) ; ; EXTERN_C const IID IID_IUnknown; ; ; extern "C++" ; ; { ; ; MIDL_INTERFACE("00000000-0000-0000-C000-000000000046") ; ; IUnknown ; ; { ; ; public: ; ; BEGIN_INTERFACE ; ; virtual HRESULT STDMETHODCALLTYPE QueryInterface( ; ; /* [in] */ REFIID riid, ; ; /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *ppvObject) = 0; ; ; ; ; virtual ULONG STDMETHODCALLTYPE AddRef( void) = 0; ; ; ; ; virtual ULONG STDMETHODCALLTYPE Release( void) = 0; ; ; ; ; template<class Q> ; ; HRESULT STDMETHODCALLTYPE QueryInterface(Q** pp) ; ; { ; ; return QueryInterface(__uuidof(Q), (void **)pp); ; ; } ; ; ; ; END_INTERFACE ; ; }; ;IUnknown interface---------------------------------------------------------;IUnknown interface ;------------------------------------------;Virtual Methods Table Of IPicture interface ;Virtual Methods Table Of IPicture interface ;virtual HRESULT QueryInterface() In (IUnknown interface) ==> Virtual Method Number Is 1 ;virtual ULONG AddRef() In (IUnknown interface) ==> Virtual Method Number Is 2 ;virtual ULONG Release() In (IUnknown interface) ==> Virtual Method Number Is 3 ;virtual HRESULT get_Handle() In (IPicture interface) ==> Virtual Method Number Is 4 ;virtual HRESULT get_hPal() In (IPicture interface) ==> Virtual Method Number Is 5 ;virtual HRESULT get_Type() In (IPicture interface) ==> Virtual Method Number Is 6 ;virtual HRESULT get_Width() In (IPicture interface) ==> Virtual Method Number Is 7 ;virtual HRESULT get_Height() In (IPicture interface) ==> Virtual Method Number Is 8 ;virtual HRESULT Render() In (IPicture interface) ==> Virtual Method Number Is 9 ;virtual HRESULT set_hPal() In (IPicture interface) ==> Virtual Method Number Is 10 ;virtual HRESULT get_CurDC() In (IPicture interface) ==> Virtual Method Number Is 11 ;virtual HRESULT SelectPicture() In (IPicture interface) ==> Virtual Method Number Is 12 ;virtual HRESULT get_KeepOriginalFormat() In (IPicture interface) ==> Virtual Method Number Is 13 ;virtual HRESULT put_KeepOriginalFormat() In (IPicture interface) ==> Virtual Method Number Is 14 ;virtual HRESULT PictureChanged() In (IPicture interface) ==> Virtual Method Number Is 15 ;virtual HRESULT SaveAsFile() In (IPicture interface) ==> Virtual Method Number Is 16 ;virtual HRESULT get_Attributes() In (IPicture interface) ==> Virtual Method Number Is 17 ;The Count Of Virtual Methods Is 17 ;------------------------------------------;Virtual Methods Table Of IPicture interface $IPicture = GetIPictureInterface("Image.jpg") ;-------------------------------------------------- ;-------------------------------------------------- ;////////////////////////////////////////////////// ;-------------------------------------------------- ; C++ virtual HRESULT STDMETHODCALLTYPE get_Handle(OLE_HANDLE __RPC_FAR *pHandle); ;get_Handle() Virtual Method Number Is 4 ;InterfaceCall($Inface,$ReturnType,$MethodNum,$Type1 = 0,$Param1 = 0) ;$Inface = $IPicture ;$ReturnType = "Long" Or HRESULT ;$MethodNum = 4 // Virtual Method Number ;$Type1 = "ptr*" Out Ptr ;$Param1 = 0 $Rt = InterfaceCall($IPicture,"long",4,"ptr*",0) ;Return Array Of DllCallAddress if Not @error Then $Handle = $Rt[1] MsgBox(0,"get_Handle","Image Handle Is " & $Handle) EndIf ;-------------------------------------------------- ;////////////////////////////////////////////////// ;C ++ virtual HRESULT STDMETHODCALLTYPE get_Type(SHORT __RPC_FAR *pType); ;get_Type() Virtual Method Number Is 6 ;InterfaceCall($Inface,$ReturnType,$MethodNum,$Type1 = 0,$Param1 = 0) ;$Inface = $IPicture ;$ReturnType = "Long" Or HRESULT ;$MethodNum = 6 // Virtual Method Number ;$Type1 = "SHORT*" Out SHORT ;$Param1 = 0 $Rt = InterfaceCall($IPicture,"long",6,"SHORT*",0) ;Return Array Of DllCallAddress if Not @error Then $Type = $Rt[1] MsgBox(0,"get_Type()","Image Type Is " & $Type) EndIf ;virtual HRESULT STDMETHODCALLTYPE get_Width(OLE_XSIZE_HIMETRIC __RPC_FAR *pWidth); ;get_Width() Virtual Method Number Is 7 ;InterfaceCall($Inface,$ReturnType,$MethodNum,$Type1 = 0,$Param1 = 0) ;$Inface = $IPicture ;$ReturnType = "Long" Or HRESULT ;$MethodNum = 7 // Virtual Method Number ;$Type1 = "LONG*" Out LONG Or Out OLE_XSIZE_HIMETRIC ;$Param1 = 0 $Rt = InterfaceCall($IPicture,"long",7,"LONG*",0) ;Return Array Of DllCallAddress if Not @error Then $Width = $Rt[1] $Width = MulDiv($Width,GetDeviceCaps(GetDC(0),88),2540); 88 => LOGPIXELSX MsgBox(0,"get_Width()","Image Width Is " & $Width) EndIf ;C++ virtual HRESULT STDMETHODCALLTYPE get_Height(OLE_YSIZE_HIMETRIC __RPC_FAR *pHeight) ;get_Height() Virtual Method Number Is 8 ;InterfaceCall($Inface,$ReturnType,$MethodNum,$Type1 = 0,$Param1 = 0) ;$Inface = $IPicture ;$ReturnType = "Long" Or HRESULT ;$MethodNum = 8 // Virtual Method Number ;$Type1 = "LONG*" Out LONG Or Out OLE_YSIZE_HIMETRIC ;$Param1 = 0 $Rt = InterfaceCall($IPicture,"long",8,"LONG*",0) ;Return Array Of DllCallAddress if Not @error Then $Height = $Rt[1] $Height = MulDiv($Height,GetDeviceCaps(GetDC(0),90),2540); 90 => LOGPIXELSY MsgBox(0,"get_Height()","Image Height Is " & $Height) EndIf Func GetIPictureInterface($ImageFileName) Local $nBytes $FileSize = FileGetSize($ImageFileName) + 1 if @error Then Return SetError(1,0,0) $tBuffer = DllStructCreate("byte[" & $FileSize & "]") $hFile = _WinAPI_CreateFile($ImageFileName, 2, 2) if @error Then Return SetError(2,0,0) _WinAPI_ReadFile($hFile,DllStructGetPtr($tBuffer),$FileSize,$nBytes) if @error Then Return SetError(3,0,0) _WinAPI_CloseHandle($hFile) $LPVOID = DllStructGetPtr($tBuffer) $hMem = GlobalAlloc(0x0042,$FileSize) ;$GHND = 0x0042 if @error Then SetError(4,0,0) $hLock = GlobalLock($hMem) if @error Then GlobalFree($hMem) Return SetError(5,0,0) EndIf MoveMemory($LPVOID,$hLock,$FileSize) $lpstream = CreateStreamOnHGlobal($hLock,True) if @error Then SetError(6,0,0) $riid = IIDFromString("{7BF80980-BF32-101A-8BBB-00AA00300CAB}") if @error Then SetError(7,0,0) $HRESULT = DllCall($OleAut32,"LONG","OleLoadPicture","PTR",$lpstream,"LONG", _ $FileSize,"BOOL",True,"ptr",DllStructGetPtr($riid),"PTR*",0) if @error Or $HRESULT[0] <> 0 Then GlobalUnlock($hMem) GlobalFree($hMem) Return SetError(8,0,0) EndIf GlobalUnlock($hMem) GlobalFree($hMem) $IPicture = $HRESULT[5] Return SetError(0,0,$IPicture) EndFunc Func GlobalAlloc($uFlags,$dwBytes) $HGLOBAL = DllCall("Kernel32.dll","ptr","GlobalAlloc","UINT",$uFlags,"ULONG_PTR",$dwBytes) if @error Or $HGLOBAL[0] = 0 Then Return SetError(1,0,0) Return SetError(0,0,$HGLOBAL[0]) EndFunc Func GlobalLock($hMem) $LPVOID = DllCall("Kernel32.dll","ptr","GlobalLock","ptr",$hMem) if @error Or $LPVOID[0] = 0 Then Return SetError(1,0,0) Return SetError(0,0,$LPVOID[0]) EndFunc Func GlobalUnlock($hMem) $BOOL = DllCall("Kernel32.dll","BOOL","GlobalUnlock","ptr",$hMem) if @error Or $BOOL[0] = 0 Then Return SetError(1,0,0) Return SetError(0,$BOOL[0]) EndFunc Func GlobalFree($hMem) $HGLOBAL = DllCall("Kernel32.dll","ULONG_PTR","GlobalFree","ptr",$hMem) if (@error Or ($HGLOBAL[0])) Then Return SetError(1,0,$HGLOBAL[0]) Return SetError(0,0,0) EndFunc Func CreateStreamOnHGlobal($hGlobal,$fDeleteOnRelease) $WINOLE = DllCall("Ole32.dll","PTR","CreateStreamOnHGlobal","ptr",$hGlobal,"BOOL",$fDeleteOnRelease _ ,"PTR*",0) if @error Or $WINOLE[0] <> 0 Then Return SetError(1,0,0) Return SetError(0,0,$WINOLE[3]) EndFunc Func MulDiv($nNumber,$nNumerator,$nDenominator) $Rt = DllCall("Kernel32.dll","int","MulDiv","int",$nNumber,"int",$nNumerator,"int",$nDenominator) Return $Rt[0] EndFunc Func GetDeviceCaps($hdc,$nIndex) $Rt = DllCall("Gdi32.dll","int","GetDeviceCaps","ptr",$hdc,"int",$nIndex) Return $Rt[0] EndFunc Func GetDC($hWnd) $HDC = DllCall("User32.dll","ptr","GetDC","ptr",$hWnd) if @error Or $HDC[0] = 0 Then Return SetError(1,0,0) Return SetError(0,0,$HDC[0]) EndFunc Func MoveMemory($Source,$Destination,$Length) DllCall("Kernel32.dll","none","RtlMoveMemory","PTR",$Destination,"PTR",$Source,"INT",$Length) EndFunc IRichEditOleInterface.au3 #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiRichEdit.au3> #include <SendMessage.au3> #include "InterfaceCall.au3" $hGui = GUICreate("InsertObject Example",500,390) $hRichEdit = _GUICtrlRichEdit_Create($hGui,"", 10, 10,480,300, _ BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL)) $Button1 = GUICtrlCreateButton("InsertObject",10,320,200,50) GUICtrlSetFont(-1,18,600) GUISetState() InsertObject($hRichEdit,@ScriptDir & "\Image.bmp") While True $iMsg = GUIGetMsg() Select Case $iMsg = $GUI_EVENT_CLOSE _GUICtrlRichEdit_Destroy($hRichEdit) Exit Case $iMsg = $Button1 $var = FileOpenDialog("", @MyDocumentsDir & "\","All (*.*)", 1 + 4) if Not @error Then InsertObject($hRichEdit,$var) EndIf EndSelect WEnd ;http://msdn.microsoft.com/en-us/library/windows/desktop/dd387916%28v=vs.85%29.aspx ;Use a Rich Edit Interface ;Rich edit controls expose some of their functionality through Component Object Model ;(COM) interfaces. By obtaining an interface from a control, you gain the ability to ;work with other objects within the control. You can obtain this interface by sending ;the EM_GETOLEINTERFACE message. From the IRichEditOle interface, you can then obtain ;interfaces used in the Text Object Model. ;Another interface, IRichEditOleCallback, is implemented by applications to define the ;behavior of the control when it interacts with objects. ;Insert an Object into a Rich Edit Control ;The following code example inserts a file object into a rich edit control. If a program ;is associated with the file type on the user's machine (for example, Microsoft Excel for ;an .xls file), the contents of the file display in the control; otherwise, an icon appears. Func InsertObject($hRichEdit,$pszFileName) Local $hr = 0, $Rt = 0 , $EM_GETOLEINTERFACE = 1084 , $pRichEditOle = 0 $pRichEditOle = _SendMessage($hRichEdit,$EM_GETOLEINTERFACE,0,0,4,"wparam","ptr*") if ($pRichEditOle == 0) Then return FALSE; EndIf Local $pLockBytes = 0 $hr = DllCall("Ole32.dll","long","CreateILockBytesOnHGlobal","ptr",0,"BOOL",True,"Ptr*",0) if (@error Or $hr[0] <> 0) Then return FALSE; EndIf $pLockBytes = $hr[3] Local $pStorage = 0 $hr = DllCall("Ole32.dll","long","StgCreateDocfileOnILockBytes","ptr",$pLockBytes, _ "DWORD",BitOR(0x00000010,0x00001000,0x00000002), _ "DWORD",0,"Ptr*",0) if (@error Or $hr[0] <> 0) Then return FALSE; EndIf $pStorage = $hr[4] $tagFORMATETC = "int cfFormat;ptr ptd;DWORD dwAspect;LONG lindex;DWORD tymed" $formatEtc = DllStructCreate($tagFORMATETC) DllStructSetData($formatEtc,"cfFormat",0) DllStructSetData($formatEtc,"ptd",0) DllStructSetData($formatEtc,"dwAspect",1) DllStructSetData($formatEtc,"lindex",-1) DllStructSetData($formatEtc,"tymed",0) Local $pClientSite ;hr = pRichEditOle->GetClientSite(&pClientSite); ;GetClientSite Virtual Method Number Of GetClientSite Is 4 in (IRichEditOle interface) $hr = InterfaceCall($pRichEditOle,"long",4,"ptr*",0) if (@error Or $hr[0] <> 0) Then return FALSE; EndIf $pClientSite = $hr[1] Local $pUnk,$clsid = CLSIDFromString("{00000000-0000-0000-0000-000000000000}") Local $IID_IUnknown = IIDFromString("{00000000-0000-0000-C000-000000000046}") $hr = DllCall("Ole32.dll","long","OleCreateFromFile","ptr",DllStructGetPtr($clsid),"wstr", _ $pszFileName,"ptr",DllStructGetPtr($IID_IUnknown),"DWORD",1,"ptr",DllStructGetPtr($formatEtc) _ ,"ptr",$pClientSite,"ptr",$pStorage,"Ptr*",0) ;pClientSite->Release(); ;IOleClientSite interface inherits from the IUnknown Or IOleClientSite : public IUnknown ;Release() Virtual Method Number Of Release() Is 3 In (IOleClientSite interface) InterfaceCall($pClientSite,"long",3) if ($hr[0] <> 0) Then return FALSE; EndIf $pUnk = $hr[8] Local $pObject,$IID_IOleObject = IIDFromString("{00000112-0000-0000-C000-000000000046}") ;hr = pUnk->QueryInterface(IID_IOleObject, (void**)&pObject); ;New pUnk (IOleObject) interface inherits from the IUnknown Or IOleObject : public IUnknown ;QueryInterface() Virtual Method Number Of QueryInterface() Is 1 In (IOleObject) $hr = InterfaceCall($pUnk,"long",1,"ptr",DllStructGetPtr($IID_IOleObject),"ptr*",0) ;Release() Virtual Method Number Of Release() Is 3 In (IOleObject interface) ;pUnk->Release(); InterfaceCall($pUnk,"long",3) if ($hr[0] <> 0) Then return FALSE; EndIf $pObject = $hr[2] DllCall("Ole32.dll","long","OleSetContainedObject","ptr",$pObject,"BOOL",True) $tagREOBJECT = "DWORD cbStruct;LONG cp;ulong Data1;ushort Data2;ushort Data3;byte Data4[8]" & _ ";ptr poleobj;ptr pstg;ptr polesite;long x;long y;DWORD dvaspect;DWORD dwFlags;DWORD dwUser" $reobject = DllStructCreate($tagREOBJECT) DllStructSetData($reobject,"cbStruct",DllStructGetSize($reobject)) ;hr = pObject->GetUserClassID(&clsid); ;GetUserClassID Virtual Method Number Of GetUserClassID Is 16 in (IOleObject interface) $hr = InterfaceCall($pObject,"long",16,"ptr",DllStructGetPtr($clsid)) if (@error Or $hr[0] <> 0) Then ;pObject->Release(); ;Release() Virtual Method Number Of Release() Is 3 In (IOleObject interface) InterfaceCall($pObject,"long",3) return FALSE EndIf MoveMemory(DllStructGetPtr($clsid),DllStructGetPtr($reobject) + 8,16) ;8 ==> SizeOf "DWORD cbStruct;LONG cp;" ;16 ==> sizeOf $clsid DllStructSetData($reobject,"cp",-1) DllStructSetData($reobject,"dvaspect",1) DllStructSetData($reobject,"dwFlags",BitOR(0x00000001,0x00000002)) DllStructSetData($reobject,"dwUser",0) DllStructSetData($reobject,"poleobj",$pObject) DllStructSetData($reobject,"polesite",$pClientSite) DllStructSetData($reobject,"pstg",$pStorage) $SIZEL = DllStructCreate("long;long"); DllStructSetData($reobject,"SIZEL",DllStructGetPtr($SIZEL)) _SendMessage($hRichEdit, 0xB1, 0, -1);EM_SETSEL $Rt = _SendMessage($hRichEdit, 0xB0,0,0,-1,"DWORD*","DWORD*");EM_GETSEL Local $dwStart = $Rt[3], $dwEnd = $Rt[4] _SendMessage($hRichEdit,0xB1, $dwEnd+1, $dwEnd+1);EM_SETSEL _SendMessage($hRichEdit, 0xC2, TRUE,@CRLF,0,"BOOL","wstr");EM_REPLACESEL ;hr = pRichEditOle->InsertObject(&reobject); ;InsertObject Virtual Method Number Of InsertObject Is 8 in (IRichEditOle interface) $hr = InterfaceCall($pRichEditOle,"long",8,"ptr",DllStructGetPtr($reobject)) ;pObject->Release(); ;Release() Virtual Method Number Of Release() Is 3 In (IOleObject interface) InterfaceCall($pObject,"long",3) ;pRichEditOle->Release(); ;Release() Virtual Method Number Of Release() Is 3 In (IRichEditOle interface) InterfaceCall($pRichEditOle,"long",3) if ($hr[0] <> 0) Then return FALSE; EndIf return TRUE; EndFunc Func MoveMemory($Source,$Destination,$Length) DllCall("Kernel32.dll","none","RtlMoveMemory","PTR",$Destination,"PTR",$Source,"INT",$Length) EndFunc
    1 point
  4. michaelslamet

    Where to begin?

    Are you save the compiled script as "notepad.exe" ? Try to save it as another name
    1 point
  5. TechCoder

    Where to begin?

    thanks for the correction on that. I'm pretty new to AutoIt and only used the 'most' option so far, though I read about the OnEventMode and will, one day, mess around with it to see how it works (my latest project is rather large - porting over a package of tools from .php to run on a local machine with GUI, etc...) and OnEventMode looks like it may be a good choice for my programming style, though trying to learn the basics right now.
    1 point
  6. TechCoder

    Where to begin?

    EDIT: (I tried the code - it works like JLogan3o13 says. - even complied)
    1 point
  7. TechCoder

    Where to begin?

    in every _GUI function in AutoIt you will see something like this While 1 $GUIMsg = GUIGetMsg() Switch $GUIMsg Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd that is needed to be able to close the window when clicking on the red X in the corner. Also, I don't know about others, but I think you should post your code in this forum, not on another where things need to be downloaded, etc.
    1 point
  8. JLogan3o13

    Where to begin?

    This is probably one of the hardest issues when you first start. I recently directed someone to AutoIt, and he remarked that he is likewise struggling to come up with his first idea. Once you have something in mind that you want to accomplish, however, your learning will begin to pick up speed.
    1 point
  9. Please read first post again.
    1 point
  10. jaberwacky

    Where to begin?

    Well, just take the advice dispensed in the previous posts and start somewhere. You can always ask here and in other forums when you have questions.
    1 point
  11. Kovacic, Does this help at all? #include <GUIConstantsEx.au3> #include <Array.au3> #Include <GuiListBox.au3> Global $hGUI, $hInput, $hList, $sPartialData, $asKeyWords[100] ; Create list full of random 5 character "words" Keywords() $hGUI = GUICreate("Example", 200, 400) $hInput = GUICtrlCreateInput("", 5, 5, 190, 20) $hList = GUICtrlCreateList("", 5, 30, 190, 325, BitOR(0x00100000, 0x00200000)) $hButton = GUICtrlCreateButton("Read", 60, 360, 80, 30) $hUP = GUICtrlCreateDummy() $hDOWN = GUICtrlCreateDummy() $hENTER = GUICtrlCreateDummy() GUISetState(@SW_SHOW, $hGUI) ; Set accelerators for Cursor up/down and Enter Dim $AccelKeys[3][2]=[["{UP}", $hUP], ["{DOWN}", $hDOWN], ["{ENTER}", $hENTER]] GUISetAccelerators($AccelKeys) $sCurr_Input = "" $iCurrIndex = -1 While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $hList $sChosen = GUICtrlRead($hList) If $sChosen <> "" Then GUICtrlSetData($hInput, $sChosen) Case $hButton If $sPartialData <> "" Then $sFinal = GUICtrlRead($hInput) If _ArraySearch($asKeyWords, $sFinal) > 0 Then MsgBox(0, "Chosen", $sFinal) EndIf EndIf Case $hUP If $sPartialData <> "" Then $iCurrIndex -= 1 If $iCurrIndex < 0 Then $iCurrIndex = 0 _GUICtrlListBox_SetCurSel($hList, $iCurrIndex) EndIf Case $hDOWN If $sPartialData <> "" Then $iTotal = _GUICtrlListBox_GetCount($hList) $iCurrIndex += 1 If $iCurrIndex > $iTotal - 1 Then $iCurrIndex = $iTotal - 1 _GUICtrlListBox_SetCurSel($hList, $iCurrIndex) EndIf Case $hENTER If $iCurrIndex <> -1 Then $sText = _GUICtrlListBox_GetText($hList, $iCurrIndex) GUICtrlSetData($hInput, $sText) $iCurrIndex = -1 _GUICtrlListBox_SetCurSel($hList, $iCurrIndex) EndIf EndSwitch ; If input has changed, refill list with matching items If GUICtrlRead($hInput) <> $sCurr_Input Then CheckInputText() $sCurr_Input = GUICtrlRead($hInput) EndIf WEnd Func CheckInputText() $sPartialData = "|" ; Start with delimiter so new data always replaces old Local $sInput = GUICtrlRead($hInput) If $sInput <> "" Then For $i = 0 To 99 If StringInStr($asKeyWords[$i], $sInput) <> 0 Then $sPartialData &= $asKeyWords[$i] & "|" Next GUICtrlSetData($hList, $sPartialData) EndIf EndFunc ;==>CheckInputText Func Keywords() Local $sData For $i = 0 To 99 $asKeyWords[$i] = Chr(Random(65, 90, 1)) & Chr(Random(65, 90, 1)) & Chr(Random(65, 90, 1)) & Chr(Random(65, 90, 1)) $sData &= $asKeyWords[$i] & "|" Next GUICtrlSetData($hList, $sData) $iCurrIndex = -1 _GUICtrlListBox_SetCurSel($hList, $iCurrIndex) EndFunc ;==>Keywords Please ask if anything is unclear. M23
    1 point
  12. michaelslamet

    Where to begin?

    That one is pretty basic. It is a tutorial for totally new developers Take sometime to read, try, read, try it over and over again. Just dont spend your whole saturday and sunday for this, or you'll need to sleep at the sofa on the next day (personal experience)
    1 point
  13. michaelslamet

    Where to begin?

    Feel like I type that one myself
    1 point
  14. Hi FireStorm001, problem is in your hotkey for exit. When the script sends letter "e" in word "Hello" it ends script. Letter "p" for pause....just the same
    1 point
  15. I think this piece of code in callback function determines that the message came from input, If $nID = $IP Then $hCtrl = $lParam If $nNotifyCode = $EN_CHANGE Then $txt = GUICtrlRead($IP) For $n = 1 To UBound($MyVal) - 1 If StringCompare(StringLeft($MyVal[$n], StringLen($txt)), $txt) = 0 Then GUICtrlSetData($Edit1, $MyVal[$n]) if GUICtrlRead($IP) then GUICtrlSetState($Edit1, $GUI_show) else GUICtrlSetState($Edit1, $GUI_Hide) endif ExitLoop EndIf Next EndIf EndIf you might have to code another condition for your list box.
    1 point
  16. Put to the start of your script a cmd line "switcher" and rewrite the script where each subscript is launched with an argument of your choice. Like that you will only have one executable !
    1 point
  17. I've found the relevant bits of code where this occurs. COM is returning an S_OK result code with a variant set to VT_ERROR. When that variant gets copied the code was missing something. I've fixed that now so that it assigns the result a copy of the VT_ERROR COM object. That at least gives the same output as 3.3.8.1.  Wondering if I should assign it as an AutoIt null keyword or VT_NULL instead. Or even kick off the COM error handler. 
    1 point
  18. I mean if you want to automate your window while the user can continue working you can place it outside your Monitor reach Lets say you place it on x = 4000 y=4000 But if you Need graphical Information ( lets say you must click on a Point that is in a certain color ) then you must send a "wm_paint" message to the window manually because Windows does not repaint Windows outside the Monitor reach regards Blues
    1 point
  19. Melba23

    Where to begin?

    Bearpocalypse, Delighted to hear that. I would like to think this opinion is shared by the overwhelming majority of members. Certainly those who make some effort to help themselves - it is only the lazy ones who expect everything done for them that tend to get short shrift. onlinethlive, Reading the Help file (at least the first few sections - Using AutoIt, Tutorials and the first couple of References) will help you enormously. You should also look at this excellent tutorial - as you have already been told, you will find other tutorials in the Wiki. M23
    1 point
  20. Rogue5099

    Where to begin?

    Within ProgramFilesAutoItExamples folder there are several examples that you can see what happens and what the code does as it is ran.
    1 point
  21. somdcomputerguy

    Where to begin?

    I'll agree with michaelslamet's post also. There is example code for just about every native AutoIt function in the Help file/manual/documentation. Run some of those examples to see how it all works. And after you've read thru the Help file, read thru it again! Welcome to this forum!
    1 point
  22. jaberwacky

    Where to begin?

    Armed with the resources mentioned above ask yourself what sort of program do you want to make? I'd start small though and stick with simple stuff until you learn more. Basically, learn the basic concepts of programming first. Some concepts include problem solving, sequence, selection, iteration, etc.
    1 point
  23. michaelslamet

    Where to begin?

    Hi, Welcome to the forum! AutoIT help file and wiki is a great place to start. Please feel free to ask in this forum, but make sure you've read the forum rules.
    1 point
  24. So I made some other experiments. It turns out, that neither pixelGetColor pixelSearce or any other device context operation can gather graphical information from the hidden desktop even if you manually send paint messages So unfortunately my udf is not appropriate for graphical operations and image regognition. I would recommend for that - virtual machines - out of monitor region ( manual repaint ) So far. best regards
    1 point
  25. To make it simple so you can understand: $Array[3] Is made by: $Array[0] $Array[1] $Array[2] As the count of an array starts from 0 everytime. So if I want to put A, B, C in an array i must declare it like this $Array[3]=[A,B,C] OR $Array[0]="A",$Array[1]="B",$Array[2]="C" Those 0, 1, 2 are called "indexes", so that's what is an Index. To call an element randomly you can do this $x=$Array[Random(0,2,1)] and it will call a random value included from 0 to 2. By the way, this can call more than once the same value, as a random number cal can draw numbers like this: 1,0,2,2,2,0,0,1,2,2,1,0 and so on. To extract one element only once look at the useful "Deck Shuffle" function that is listed above. I used it and it was very useful. Hope to have made it clear.
    1 point
×
×
  • Create New...