Jump to content
Sign in to follow this  
b0x4it

PostMessage from Total Commander to Total Commander

Recommended Posts

b0x4it

I am trying to use postmessage with Total Commander using AutoIt just like what I did with AutoHotkey. What I did with AutoHotkey is that I created a ahk file and put a button at the TotalCommander toolbar that calls the ahk file. The ahk file includes:

PostMessage, 0x433, 2018, 0,, A

the interesting point is that since the TotalCommander in the active windows when I push the button on its toolbar, the there is no need to find the handle of total commander windows. I tried to do the same using AutoIt. So I made a au3 file that includes:

$hwnd = WinGetHandle("Total Commander")

DllCall("user32.dll", "int", "SendMessage", "hwnd", $hwnd , "int" , 1075 , "int", 2018)

but whenever I run it AutoIt crashes. I reckon that $hwnd is the problem (not sure). My question is that how I can call SendMessage or PostMessage function without specifying $hwnd. Is this possible in AutoIt?

the error that windows shows when AutoIt crashes is:

Problem signature:

Problem Event Name: BEX

Application Name: AutoIt3.exe

Application Version: 3.3.6.1

Application Timestamp: 4bc81615

Fault Module Name: StackHash_0a9e

Fault Module Version: 0.0.0.0

Fault Module Timestamp: 00000000

Exception Offset: 004cf186

Exception Code: c0000096

Exception Data: badc0de1

OS Version: 6.1.7600.2.0.0.256.48

Locale ID: 3081

Additional Information 1: 0a9e

Additional Information 2: 0a9e372d3b4ad19135b953a78882e789

Additional Information 3: 0a9e

Additional Information 4: 0a9e372d3b4ad19135b953a78882e789

Any help is appreciated!

Share this post


Link to post
Share on other sites
PsaltyDS

Try testing $hwnd or displaying its value before the DllCall().

Also, SendMessage has another parameter for lparam, so perhaps:

$aRET = DllCall("user32.dll", "int", "SendMessage", "hwnd", $hwnd , "int" , 1075 , "int", 2018, "int", 0)

You might also try the _SendMessage() UDF, see help file.

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites
b0x4it

Thanks for the reply. Yes it works, but when I run it to for example shows the about windows of the total commander, AutoIt icon waits in systray until I close the about windows. Is there anyway to release AutoIt?

Share this post


Link to post
Share on other sites
PsaltyDS

If those two lines are all there is to the script, then the DllCall() is not completing, which means the app is not responding to the message until after the popup is handled. If there is more to the script, then we're just guessing.

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites
b0x4it

this is the whole code:

$hwnd = WinGetHandle("Total Commander") 
DllCall("user32.dll", "int", "SendMessage", "hwnd", $hwnd , "int" , 1075 , "int", 2400, "int", 0)
MsgBox(0, "aaaa", "bbbb")

so when I run it, total commander show the multi-rename windows and AutoIt icon is waiting at systray and once I close the multi-rename windows the messagebox appears. How can I ask it to not wait?

Share this post


Link to post
Share on other sites
PsaltyDS

Recode total commander to respond to the received message before the messagebox is handled. When that app chooses to reply is not in AutoIt's control.

The DllCall() is a blocking function in AutoIt, and AutoIt is single threaded. If you want to do something else before the DllCall() returns, you'll have to kick off another process before making the call.

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites
b0x4it

But when I try this code using AutoHotkey then it works perfectly (It shows the multi-rename and at the same time loads google).

PostMessage, 0x433, 2400, 0,, A 
run, iexplore.exe http://www.google.com/

So how can I do the same in AutoIt?

Actually I like the syntax of AutoIt more than AutoHotkey and I'm trying to convert my codes from AutoHotkey to AutoIt.

Share this post


Link to post
Share on other sites
b0x4it

_SendMessage () UDF is really good.

I also tried _SendMessage:

#include <SendMessage.au3>
$hwnd = WinGetHandle("Total Commander") 
_SendMessage($hWnd, 0x433 , 2400, 0)
MsgBox(0, "aaaa", "bbbb")

but it has the same problem: messagebox does not appears util I close multi-rename windows in totalcommander. Any suggestion to fix this problem?

Share this post


Link to post
Share on other sites
b0x4it

Is sounds to me like you want PostMessage, not SendMessage. You're even using PostMessage in ahk, so why don't you try that in Au3?

:)

Thank you so much. Honestly, I do not know the exact difference between these two and also the difference between using _SendMessage() and calling SendMessage through DllCall()! It would be good if someone can give me some hints.

Share this post


Link to post
Share on other sites
AdmiralAlkex

SendMessage Function

Sends the specified message to a window or windows. The SendMessage function calls the window procedure for the specified window and does not return until the window procedure has processed the message.

PostMessage Function

Places (posts) a message in the message queue associated with the thread that created the specified window and returns without waiting for the thread to process the message.

Easily found by googling the function names.

Edited by AdmiralAlkex

Share this post


Link to post
Share on other sites
PsaltyDS

Good point from AdmiralAlkex, and there's already a UDF for it:

#Include <WinAPI.au3>

; ...

_WinAPI_PostMessage($hWnd, 0x433 , 2400, 0)

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites
b0x4it

Thank you for all your useful replies. It works perfectly now!

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.