Venix Posted May 28, 2015 Share Posted May 28, 2015 Hi, I had some downtime at work so I thought why not code some AutoIT for the first time in like 2 years. I am currently trying to get a windows move state using GetGUIThreadInfo in user32.dll so I have been going through the following documentation to figure out how to do so.https://msdn.microsoft.com/en-us/library/ms633506(VS.85).aspxhttps://msdn.microsoft.com/en-us/library/ms632604(v=vs.85).aspxhttps://msdn.microsoft.com/en-us/library/ms633522(v=vs.85).aspx I think the first DLL call I need to make is to call the function GetWindowThreadProcessId. Unfortunately when I try to do so the application just crashes. I am not sure if I am doing something wrong as I have pretty much no experience calling DLL's. I have a feeling the crashing might be to do with the crap computers I'm using at work.Currently I have something along these lines. Is anyone able to give me a push in the right direction? #include <GuiConstantsEx.au3> #include <WindowsConstants.au3> #include <SendMessage.au3> Opt("MustDeclareVars") Dim $hCurrentWindow, $dllTest $hCurrentWindow = WinGetHandle("[Active]") $dllTest = DllCall("user32.dll", "DWORD", "GetWindowThreadProcessId", "HWND", $hCurrentWindow) Link to comment Share on other sites More sharing options...
Starstar Posted May 28, 2015 Share Posted May 28, 2015 (edited) $struc = "struct;DWORD lpdwProcessId;endstruct" $struccrt = DllStructCreate($struc) $hCurrentWindow = WinGetHandle("[Active]") $dllTest = DllCall("user32.dll", "DWORD", "GetWindowThreadProcessId", "HWND*", $hCurrentWindow,"ptr",DllStructGetPtr($struccrt)) MsgBox(0,"",$dllTest[0])[Edit::]Your problem is that you are trying to get Window Thread Process Id. But you are not giving a space to where to store retrieved Data(ID).Try this one... Edited May 28, 2015 by Starstar Venix 1 Life is like a coin. You can spend it Anyway as you wish and for your kind information. "you can spend it only once." Link to comment Share on other sites More sharing options...
Venix Posted May 28, 2015 Author Share Posted May 28, 2015 Unfortunately I don't have a way to actively test this at the moment because the two systems I am using are completely closed off from each other but Ill look into it when I get home. Thanks for the help Starstar. Link to comment Share on other sites More sharing options...
Starstar Posted May 28, 2015 Share Posted May 28, 2015 (edited) No problem Bro.Code has tested in win7 by me....... Edited May 28, 2015 by Starstar Life is like a coin. You can spend it Anyway as you wish and for your kind information. "you can spend it only once." Link to comment Share on other sites More sharing options...
Venix Posted May 28, 2015 Author Share Posted May 28, 2015 I typed your previous code out manually on the system I am testing on and it worked perfectly. I am going to look into Dll Structs as I don't really know what they are not something I have ever researched. Would you mind explaining why you put in "HWND*" as the parameter type rather than just "HWND".? Link to comment Share on other sites More sharing options...
Starstar Posted May 28, 2015 Share Posted May 28, 2015 (edited) I copied this line for you from help dllcall"Add * to the end of another type to pass it by reference. For example "int*" passes a pointer to an "int" type."* indicate that following one is by reference.......[Edit::]Reference means this parameter or variable has not value directly but by the other source. Edited May 28, 2015 by Starstar Life is like a coin. You can spend it Anyway as you wish and for your kind information. "you can spend it only once." Link to comment Share on other sites More sharing options...
Venix Posted May 28, 2015 Author Share Posted May 28, 2015 Cool thanks, I think GetWindowThreadProcessID returns the same value as WinGetHandle("[Active]") anyway so I don't believe this particular DLL call will be necessary in my overall solution. But of course I will need to make other calls so I can refer back to your example for that :). Link to comment Share on other sites More sharing options...
Starstar Posted May 28, 2015 Share Posted May 28, 2015 You needed or not but everything that can increase your knowledge is precious. Life is like a coin. You can spend it Anyway as you wish and for your kind information. "you can spend it only once." Link to comment Share on other sites More sharing options...
Venix Posted May 28, 2015 Author Share Posted May 28, 2015 I should be ok to continue from here, Ill probably just add to this thread if I have anymore queries on this subject. Thanks again, you have been a great help. Link to comment Share on other sites More sharing options...
Starstar Posted May 28, 2015 Share Posted May 28, 2015 I should be ok to continue from here, Ill probably just add to this thread if I have anymore queries on this subject. Thanks again, you have been a great help.My Pleasure..... Life is like a coin. You can spend it Anyway as you wish and for your kind information. "you can spend it only once." Link to comment Share on other sites More sharing options...
UEZ Posted May 28, 2015 Share Posted May 28, 2015 Have a look to_WinAPI_GetWindowThreadProcessId() Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
Venix Posted May 28, 2015 Author Share Posted May 28, 2015 (edited) Have a look to _WinAPI_GetWindowThreadProcessId() Was trying to find a WinAPI function for this but didn't see it, thanks for pointing that out. I still seem to be struggling to get back the information I am after from GetGUIThreadInfo. Just seems to be returning 0 which I believe is a failure.This is what I currently have.$hCurrentWindow = WinGetHandle("[Active]") $threadProcessID = _WinApi_GetWindowThreadProcessId($hCurrentWindow, _WinAPI_GetProcessID()) $struc = "struct:BOOL lpgui;endstruct" $struccrt = DllStructCreate($struc) $dllTest = DllCall("user32.dll", "BOOL", "GetGUIThreadInfo", "DWORD*", $threadProcessID, "ptr", DllStructGetPtr($struccrt))Edit::MsgBox(0, "", $dllTest[0])Do any of you see any noticeable errors? Edited May 28, 2015 by Venix Code Error Link to comment Share on other sites More sharing options...
Starstar Posted May 28, 2015 Share Posted May 28, 2015 (edited) Your structure is wrong....Try some one like this...$struct2 = "struct;DWORD cbSize;DWORD flags;HWND hwndActive;HWND hwndFocus;HWND hwndCapture;HWND hwndMenuOwner;HWND hwndMoveSize;HWND hwndCaret;RECT rcCaret;endstruct" $struccreat2 = DllStructCreate($struct2)and also set the size of structure.....because this function also required it.......DllStructSetData($struccreat2,"cbSize", DllStructGetSize($struccreat2)) Edited May 28, 2015 by Starstar Life is like a coin. You can spend it Anyway as you wish and for your kind information. "you can spend it only once." Link to comment Share on other sites More sharing options...
Venix Posted May 28, 2015 Author Share Posted May 28, 2015 (edited) Alright thanks, I just made an assumption for the structure based on the data that was in the last one. Do you know of any resources that explain the structure as I would like to learn? Edited May 28, 2015 by Venix Link to comment Share on other sites More sharing options...
Starstar Posted May 28, 2015 Share Posted May 28, 2015 (edited) https://msdn.microsoft.com/en-us/library/windows/desktop/ms632604(v=vs.85).aspxHere is your structure information.You have nothing to do just write the type(like dword ,int ,str) of a variable and the name of variable as you wish.......... Edited May 28, 2015 by Starstar Life is like a coin. You can spend it Anyway as you wish and for your kind information. "you can spend it only once." Link to comment Share on other sites More sharing options...
Venix Posted May 28, 2015 Author Share Posted May 28, 2015 Ahh awesome, that makes sence now. Link to comment Share on other sites More sharing options...
Starstar Posted May 29, 2015 Share Posted May 29, 2015 Ahh awesome, that makes sence now. Good keep it up...... Life is like a coin. You can spend it Anyway as you wish and for your kind information. "you can spend it only once." 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