hp38guser Posted August 22, 2008 Share Posted August 22, 2008 (edited) I'm converting my existing AutoIt script to Object Pascal (Inno Setup). I can access AutoIt functions and even the WinExists function works but I have to specify a text to search for. When using null I get an Acces Violation error: Read of Address 00000000. When I do specify a window text to search for it works, but how can I use null as a parameter? Other external dlls accept null parameters, but I need this to work with AutoItX. function AU3_WinExists( title: string; text: string ): integer; external 'AU3_WinExists@files:autoitx3.dll'; if AU3_WinExists('Notepad', '') <> 0 then MsgBox('AutoIt detected Notepad', mbError, mb_OK); I tested using AutoItX 3.2.12.1 and 3.2.13.7 beta. Edited August 22, 2008 by hp38guser Link to comment Share on other sites More sharing options...
Richard Robertson Posted August 23, 2008 Share Posted August 23, 2008 That looks more like a problem with Object Pascal. It's passing a null instead of a blank string. I don't know enough about the language to tell you how to make it do otherwise, but I'm guessing that is the problem. Link to comment Share on other sites More sharing options...
hp38guser Posted August 24, 2008 Author Share Posted August 24, 2008 That looks more like a problem with Object Pascal. It's passing a null instead of a blank string. I don't know enough about the language to tell you how to make it do otherwise, but I'm guessing that is the problem.I'm still a novice programmer, but what's the difference between an empty string and null? I might be able to use SetLength(Str, 0) to create an empty string. Thanks anyway Link to comment Share on other sites More sharing options...
hp38guser Posted August 24, 2008 Author Share Posted August 24, 2008 I tried using Chr(0) as parameter and it seems to fix it. Thanks Link to comment Share on other sites More sharing options...
Richard Robertson Posted August 25, 2008 Share Posted August 25, 2008 (edited) The difference between an empty string and null is that the empty string is a value. It's a string with a length of 0 characters. A null on the other hand is a value given to a pointer to indicate that it doesn't contain any value. Like, think of memory as a set of boxes. We've got a box for a string. The empty string won't have any letters in its "box." The null, doesn't even have a box. Does that make sense? Chr(0) isn't exactly the right solution, but it will work. Edited August 25, 2008 by Richard Robertson Link to comment Share on other sites More sharing options...
martin Posted September 27, 2008 Share Posted September 27, 2008 The difference between an empty string and null is that the empty string is a value. It's a string with a length of 0 characters. A null on the other hand is a value given to a pointer to indicate that it doesn't contain any value.Like, think of memory as a set of boxes. We've got a box for a string. The empty string won't have any letters in its "box." The null, doesn't even have a box. Does that make sense?Chr(0) isn't exactly the right solution, but it will work.A String in Pascal is not a pointer to a char array as a string is in C so I think it should be converted to Pchar. Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
Richard Robertson Posted September 27, 2008 Share Posted September 27, 2008 C++ doesn't handle Pchar, Martin. If the Pascal is going to make a call to the dll, it will have to be in a form that the dll will understand. Link to comment Share on other sites More sharing options...
Proph Posted November 7, 2008 Share Posted November 7, 2008 I could be wrong... but I got a simular issue in autoit. Basically I had a loop that would wait until a Window does not exist and then ExitLoop... but it would never detect that the window did not exist anymore. Even though there were no windows with that name. I noticed that it would only work if I used a text in it. Does not work when the window is closed: While 1 If Not WinExists('SUPERAntiSpyware') Then Exitloop Sleep(100) WEnd This does work (Thanks to the person who started this thread for the idea): While 1 If Not WinExists('SUPERAntiSpyware', chr(0)) Then Exitloop Sleep(100) WEnd This happens with the latest stable and Beta release of Autoit. Can others test this and see what results they get? I really think there is a bug here. Link to comment Share on other sites More sharing options...
Richard Robertson Posted November 7, 2008 Share Posted November 7, 2008 This question doesn't belong in this forum. I cannot say why that would happen, have you tried with other window titles? Are you 100% sure the window is actually closed and not just hidden? Many programs will hide the window instead of destroy it so it can be loaded again later. Link to comment Share on other sites More sharing options...
Proph Posted November 12, 2008 Share Posted November 12, 2008 (edited) Edit: Nevemind. You were right. It was a hidden window. Edited November 12, 2008 by Proph 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