GrayFox Posted April 4, 2010 Share Posted April 4, 2010 Does anyone know why none of the following code snippets work? Basically, I want to rename the window title of any new notepad documents. #include <WinAPI.au3> #include <Misc.au3> #include <WindowsConstants.au3> $var = WinList() For $i = 1 To $var[0][0] If $var[$i][0] == "Untitled - Notepad" Then $struct = DllStructCreate("char[30]") DllStructSetData($struct,1,"This doesnt work!") _SendMessage($var[$i][1],$WM_SETTEXT,0,DllStructGetPtr($struct)) EndIf Next #include <WinAPI.au3> #include <Misc.au3> #include <WindowsConstants.au3> $var = WinList() For $i = 1 To $var[0][0] If $var[$i][0] == "Untitled - Notepad" Then _SendMessage($var[$i][1], $WM_SETTEXT, 0, "This doesnt work either.", 0, "int", "str") EndIf Next This is the only one I have got working: #include <WinAPI.au3> #include <Misc.au3> #include <WindowsConstants.au3> $var = WinList() For $i = 1 To $var[0][0] If $var[$i][0] == "Untitled - Notepad" Then _WinAPI_SetWindowText($var[$i][1], "This works!") EndIf Next Thanks Link to comment Share on other sites More sharing options...
Yoriz Posted April 4, 2010 Share Posted April 4, 2010 Use 'WinSetTitle' ? GDIPlusDispose - A modified version of GDIPlus that auto disposes of its own objects before shutdown of the Dll using the same function Syntax as the original.EzMySql UDF - Use MySql Databases with autoit with syntax similar to SQLite UDF. Link to comment Share on other sites More sharing options...
GrayFox Posted April 4, 2010 Author Share Posted April 4, 2010 Thanks for your reply Yoriz, thats a great idea though unfortunately it doesnt accept handles to windows, just the title or the classname or some other complex title. (I should have stated this in the OP) that I would like to rename the window/s straight from the handle as this makes life easier. Link to comment Share on other sites More sharing options...
Yoriz Posted April 4, 2010 Share Posted April 4, 2010 It does except Handles to windows try the following Run("Notepad.exe") WinWait("Untitled - Notepad") $hWnd = WinGetHandle("Untitled - Notepad") WinSetTitle($hWnd,"","Change NotePad title with its hWnd of = " & $hWnd) GDIPlusDispose - A modified version of GDIPlus that auto disposes of its own objects before shutdown of the Dll using the same function Syntax as the original.EzMySql UDF - Use MySql Databases with autoit with syntax similar to SQLite UDF. Link to comment Share on other sites More sharing options...
GrayFox Posted April 5, 2010 Author Share Posted April 5, 2010 (edited) That works perfectly! Thanks alot Yoriz Edit: your solution solves my problem 100%, though simply out of curiosity would anyone know if its possible to achieve the same effect with _SendMessage? Edited April 5, 2010 by GrayFox Link to comment Share on other sites More sharing options...
trancexx Posted April 5, 2010 Share Posted April 5, 2010 Use _SendMessageA() or change string type to "wstr" ("wchar" for buffer). ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
GrayFox Posted April 5, 2010 Author Share Posted April 5, 2010 Thanks alot trancexx, I tested both methods and they both work great Link to comment Share on other sites More sharing options...
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