wooshaq Posted September 7, 2023 Share Posted September 7, 2023 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 More sharing options...
Developers Jos Posted September 7, 2023 Developers Share Posted September 7, 2023 (edited) 5 minutes ago, wooshaq said: autohotkey ? Post what you tried that isnt working. Edited September 7, 2023 by Jos TheDcoder 1 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 More sharing options...
wooshaq Posted September 7, 2023 Author Share Posted September 7, 2023 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 More sharing options...
Developers Jos Posted September 7, 2023 Developers Share Posted September 7, 2023 (edited) Great, then i would suggest to goto the AHK forum for support as this is the AutoIt3 forum. Or learn Autoit3. Edited September 7, 2023 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 More sharing options...
TheDcoder Posted September 7, 2023 Share Posted September 7, 2023 What the hell are those squiggly brackets?! Never seen 'em in AutoIt. EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time) DcodingTheWeb Forum - Follow for updates and Join for discussion Link to comment Share on other sites More sharing options...
wooshaq Posted September 7, 2023 Author Share Posted September 7, 2023 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 More sharing options...
argumentum Posted September 7, 2023 Share Posted September 7, 2023 1 hour ago, wooshaq said: the question is can I achieve what I'm willing the script to do? Yes. Your code logic is not there but yes. Do search the forum ( maybe via google ) and start practicing AutoIt coding. Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting. Link to comment Share on other sites More sharing options...
Nine Posted September 7, 2023 Share Posted September 7, 2023 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. “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
wooshaq Posted September 7, 2023 Author Share Posted September 7, 2023 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 More sharing options...
Nine Posted September 7, 2023 Share Posted September 7, 2023 (edited) 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 September 7, 2023 by Nine “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Trong Posted September 9, 2023 Share Posted September 9, 2023 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 TheDcoder 1 Regards, 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