zeffy Posted December 21, 2010 Posted December 21, 2010 So basically, I need to use _WinAPI_CreateWindowEx() to make a window with a specific class name, to receive WM_COPYDATA messages from another program, and process the information with my autoit script. I have no idea where to even start with this, could someone point me in the right direction?
rover Posted December 21, 2010 Posted December 21, 2010 (edited) what's so hard about searching the forum for CreateWindowEx (3 pages of results) and WM_COPYDATA (6 pages of results)? Hint: look on first page of results for CreateWindowEx Edited December 21, 2010 by rover I see fascists...
zeffy Posted December 21, 2010 Author Posted December 21, 2010 (edited) hur dur use the seach functionI have already read dozens of topics on this subject, none of them had the specific information that I asked about. Thanks for not being helpful in the slightest, next time consider contributing to a thread before you post. Edited December 21, 2010 by zeffy
zeffy Posted December 21, 2010 Author Posted December 21, 2010 I love how helpful everyone is on this forum!
zeffy Posted December 21, 2010 Author Posted December 21, 2010 (edited) Anyone feeling helpful? Edited December 21, 2010 by zeffy
Yashied Posted December 21, 2010 Posted December 21, 2010 (edited) expandcollapse popup#Include <WinAPIEx.au3> #Include <WindowsConstants.au3> Opt('MustDeclareVars', 1) Global Const $CW_USEDEFAULT = 0x80000000 Global Const $sClass = 'MyWindowClass' Global Const $sName = 'MyProg' Global $tWCEX, $tClass, $hWnd, $hProc, $hInstance, $Text = False OnAutoItExitRegister('AutoItExit') $hInstance = _WinAPI_GetModuleHandle(0) $hProc = DllCallbackRegister('_WndProc', 'lresult', 'hwnd;uint;wparam;lparam') $tClass = DllStructCreate('wchar[' & StringLen($sClass) + 1 & ']') DllStructSetData($tClass, 1, $sClass) $tWCEX = DllStructCreate($tagWNDCLASSEX) DllStructSetData($tWCEX, 'Size', DllStructGetSize($tWCEX)) DllStructSetData($tWCEX, 'Style', 0) DllStructSetData($tWCEX, 'hWndProc', DllCallbackGetPtr($hProc)) DllStructSetData($tWCEX, 'ClsExtra', 0) DllStructSetData($tWCEX, 'WndExtra', 0) DllStructSetData($tWCEX, 'hInstance', $hInstance) DllStructSetData($tWCEX, 'hIcon', 0) DllStructSetData($tWCEX, 'hCursor', 0) DllStructSetData($tWCEX, 'hBackground', 0) DllStructSetData($tWCEX, 'MenuName', 0) DllStructSetData($tWCEX, 'ClassName', DllStructGetPtr($tClass)) DllStructSetData($tWCEX, 'hIconSm', 0) _WinAPI_RegisterClassEx($tWCEX) $hWnd = _WinAPI_CreateWindowEx(0, $sClass, $sName, 0, $CW_USEDEFAULT, $CW_USEDEFAULT, $CW_USEDEFAULT, $CW_USEDEFAULT, 0) While 1 Sleep(100) If $Text Then MsgBox(262144, '', $Text) $Text = 0 EndIf WEnd Func _WinAPI_DefWindowProcW($hWnd, $iMsg, $wParam, $lParam) Local $Ret = DllCall('user32.dll', 'lresult', 'DefWindowProcW', 'hwnd', $hWnd, 'uint', $iMsg, 'wparam', $wParam, 'lparam', $lParam) If @error Then Return SetError(1, 0, 0) EndIf Return $Ret[0] EndFunc ;==>_WinAPI_DefWindowProcW Func _WndProc($hWnd, $iMsg, $wParam, $lParam) Switch $iMsg Case $WM_COPYDATA Local $tCOPYDATA = DllStructCreate('ulong_ptr;dword;ptr', $lParam) Local $tData = DllStructCreate('wchar[' & DllStructGetData($tCOPYDATA, 2) & ']', DllStructGetData($tCOPYDATA, 3)) $Text = DllStructGetData($tData, 1) Return 1 EndSwitch Return _WinAPI_DefWindowProcW($hWnd, $iMsg, $wParam, $lParam) EndFunc ;==>_WndProc Func AutoItExit() _WinAPI_DestroyWindow($hWnd) _WinAPI_UnregisterClass($sClass, $hInstance) DllCallbackFree($hProc) EndFunc ;==>AutoItExitSend a messages with the following code:#Include <WindowsConstants.au3> While 1 $Text = InputBox('', 'String to send', '', '', 300, 130, 200, 200) If Not $Text Then Exit EndIf $hWnd = WinGetHandle('[CLASS:MyWindowClass;TITLE:MyProg]') $tCOPYDATA = DllStructCreate('ulong_ptr;dword;ptr') $tData = DllStructCreate('wchar[' & StringLen($Text) + 1 & ']') DllStructSetData($tData, 1, $Text) DllStructSetData($tCOPYDATA, 2, DllStructGetSize($tData)) DllStructSetData($tCOPYDATA, 3, DllStructGetPtr($tData)) DllCall('user32.dll', 'lresult', 'SendMessage', 'hwnd', $hWnd, 'uint', $WM_COPYDATA, 'ptr', 0, 'ptr', DllStructGetPtr($tCOPYDATA)) WEnd Edited December 21, 2010 by Yashied My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More...
guinness Posted December 21, 2010 Posted December 21, 2010 Wow, incredible! Something new to study about WM_COPYDATA! Thanks UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018
Ascend4nt Posted December 22, 2010 Posted December 22, 2010 Very nice job Yashied. I was curious about implementing a windows procedure before, its nice to see a working example. My contributions: Performance Counters in Windows - Measure CPU, Disk, Network etc Performance | Network Interface Info, Statistics, and Traffic | CPU Multi-Processor Usage w/o Performance Counters | Disk and Device Read/Write Statistics | Atom Table Functions | Process, Thread, & DLL Functions UDFs | Process CPU Usage Trackers | PE File Overlay Extraction | A3X Script Extract | File + Process Imports/Exports Information | Windows Desktop Dimmer Shade | Spotlight + Focus GUI - Highlight and Dim for Eyestrain Relief | CrossHairs (FullScreen) | Rubber-Band Boxes using GUI's (_GUIBox) | GUI Fun! | IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) | Magnifier (Vista+) Functions UDF | _DLLStructDisplay (Debug!) | _EnumChildWindows (controls etc) | _FileFindEx | _ClipGetHTML | _ClipPutHTML + ClipPutHyperlink | _FileGetShortcutEx | _FilePropertiesDialog | I/O Port Functions | File(s) Drag & Drop | _RunWithReducedPrivileges | _ShellExecuteWithReducedPrivileges | _WinAPI_GetSystemInfo | dotNETGetVersions | Drive(s) Power Status | _WinGetDesktopHandle | _StringParseParameters | Screensaver, Sleep, Desktop Lock Disable | Full-Screen Crash Recovery Wrappers/Modifications of others' contributions: _DOSWildcardsToPCRegEx (original code: RobSaunder's) | WinGetAltTabWinList (original: Authenticity) UDF's added support/programming to: _ExplorerWinGetSelectedItems | MIDIEx UDF (original code: eynstyne) (All personal code/wrappers centrally located at Ascend4nt's AutoIT Code)
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now