Jump to content

posibilities of autoit and cpu usage?


wooshaq
 Share

Recommended Posts

Hello, I finally decided to experiment with automatization. Basically I need to make something rather simple with it. I use two programs: total commander  and msedge. Both maximised and what i want to do is when I run my music player (aimp) I would like to both apps to resize to acknowledge the size of the player. I tired experimenting with autohotkey and made a semiworking script that does that fairly competent but i need to iron it out since there are some things to fix but when I run the script in a loop it uses around 10% of my cpu, which is AMD 3700x. Who much power does Autoit needs to perform discribed task? And could someone help me with making such script?

Link to comment
Share on other sites

  • Developers
5 minutes ago, wooshaq said:

autohotkey

?

Post what you tried that isnt working. ;)

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

5 minutes ago, Jos said:

?

Post what you tried that isnt working. ;)

This is what I made for ahk

Loop
{
If WinExist("ahk_class TAIMPMainForm")
{
WinRestore "ahk_exe msedge.exe" ; msedge
WinMove -8,0,2118,1388,"ahk_exe msedge.exe"
WinRestore "ahk_class TTOTAL_CMD"
WinMove -8,0,2118,1388,"ahk_class TTOTAL_CMD"
}
else if WinExist("ahk_class TAIMPTrayControl")
{
WinMaximize "ahk_exe msedge.exe" ; msedge
WinMaximize "ahk_class TTOTAL_CMD"
}
else if WinClose("ahk_exe aimp.exe")
{
WinMaximize "ahk_exe msedge.exe" ; msedge
WinMaximize "ahk_class TTOTAL_CMD"
}
}

This is what I came up with but there are some things that I have problem with:

1 - script crashes when edge or total commander are closed
2 - edge and totcal commander are always maximised on aimp closed
3 - 10% cpu usage of script

Link to comment
Share on other sites

  • Developers

Great, then i would suggest to goto the AHK forum for support as this is the AutoIt3 forum. ;)

Or learn Autoit3.

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

I know this is not the correct developer, as I said I only played with ahk, i'm willing to try autoit, the question is can I achieve what I'm willing the script to do? I described the problem in the first post. does autoit have some kind of loop mode that will stay in the background and monitor if aimp is running or not and will resize the windows if necessary? And what about the cpu usage to monitor such a simple task?

Link to comment
Share on other sites

AutoIt is a very complete scripting language.  You can pretty much do everything Windows is offering.  As for your request, there is ways to trigger some code when a specific window appears which will not use much CPU in waiting.  But in order for us to help you, you will need to provide some code.

To get you started in your project, I suggest you open help file and look at _WinAPI_RegisterWindowMessage.  The example provided under this function is quite close from what you are attempting to do. 

Come back with some code, and we will be very glad to guide you.

Link to comment
Share on other sites

OK, I started from the basics:

#include <MsgBoxConstants.au3>

Example()

Func Example()

        ; Test if the window exists and display the results.
        If WinExists("[CLASS:TAIMPTrayControl]", "")  Then
                MsgBox($MB_SYSTEMMODAL, "", "Window exists")
        Else
                MsgBox($MB_SYSTEMMODAL + $MB_ICONERROR, "Error", "Window does not exist")
        EndIf

EndFunc   ;==>Example

Ok, first question. Even though aimp exists in two forms big and small, each with different class script never goes to "else" state, only when aimp is closed altogether. Please note that autohotkey could destinguish which class was present at the time. Any way to determine which class is present on the screen at given time? Note that I tired with WinActive but I want to switch between regular and mini by using minimalize button and current window will not be active anymore I think.

Link to comment
Share on other sites

Ok, first question what are the different CLASSs of aimp ?  Here a draft of how you would use it with my previous recommandation with Notepad.

#include <APISysConstants.au3>
#include <WinAPISysWin.au3>
#include <Constants.au3>

Opt("MustDeclareVars", True)

OnAutoItExitRegister(OnAutoItExit)

Global $hTarget
Global $hForm = GUICreate('')
GUIRegisterMsg(_WinAPI_RegisterWindowMessage('SHELLHOOK'), WM_SHELLHOOK)
_WinAPI_RegisterShellHookWindow($hForm)

While Sleep(100)
WEnd

Func WM_SHELLHOOK($hWnd, $iMsg, $wParam, $lParam)
  If Not $lParam Then Return
  If $lParam = WinGetHandle("[CLASS:Notepad]") Then
    ConsoleWrite($wParam & "/" & $lParam & @CRLF)
    If $wParam = $HSHELL_WINDOWCREATED Then
      ConsoleWrite("Notepad has been created" & @CRLF)
      $hTarget = $lParam
    EndIf
  ElseIf $hTarget = $lParam And $wParam = $HSHELL_WINDOWDESTROYED Then
    ConsoleWrite("Notepad has been closed" & @CRLF)
    $hTarget = 0
    Exit
  EndIf
EndFunc   ;==>WM_SHELLHOOK

Func OnAutoItExit()
    _WinAPI_DeregisterShellHookWindow($hForm)
EndFunc   ;==>OnAutoItExit

ps. do not refer to AHK anymore as I do not know anything about it.  Check the REAL classes you can find.  There are also other references you could use to get the handle (like size, position, etc).

Edited by Nine
Link to comment
Share on other sites

On 9/7/2023 at 10:27 PM, wooshaq said:

Who much power does Autoit needs to perform discribed task? 1%

And could someone help me with making such script?

How much will you pay for this request?

 

On 9/8/2023 at 4:48 AM, Nine said:

CLASSs of aimp 

AIMP.exe
>>>> Window Main <<<<
Title:    Audio/Video file name
Class:    TAIMPMainForm

>>>> Window Mini<<<<
Title:    TrayControl
Class:    TAIMPTrayControl

 

Regards,
 

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...