EvilRubberDuck Posted November 16, 2013 Posted November 16, 2013 1- So i was trying to do a macro, to change the output of the sound from my speaker to my phones. i started with this run("Control.exe Mmsys.cpl") WinWait("Som") im portuguese so som=sound xD but everytime i run this command the window opens in a diferent location (i really can't understand why), so i found this code in your forums ; Center Window on Screen ; Author cdkid and Valuater Func _Middle($win, $txt) $size = WinGetClientSize($win, $txt) Local $y = (@DesktopHeight / 2) - ($size[1] / 2) Local $x = (@DesktopWidth / 2) - ($size[0] / 2) Return WinMove($win, $txt, $x, $y) EndFunc ;==>_Middle my problem is how do i define which windows it is to move. If im not wrong $win and $txt are both variables, and from what i could understand we dont need the part of $txt right? so i could do this Func _Middle($win) $size = WinGetClientSize($win, "") Local $y = (@DesktopHeight / 2) - ($size[1] / 2) Local $x = (@DesktopWidth / 2) - ($size[0] / 2) Return WinMove($win, "", $x, $y) EndFunc ;==>_Middle now i only need to define $win but i think u need to put like this WinMove("class or title", "", $x, $y) so if i define the variable Local $win=Som but it doesn't work :/ 2- so i tried almost everything reopen the window of google chrome when its minimized, and i only found one way: Local $var = WinList() For $i = 1 To $var[0][0] ; Only display visble windows that have a title If $var[$i][0] <> "" And IsVisible($var[$i][1]) Then Local $result = StringInStr($var[$i][0], "Chrome") if $result > 0 Then WinSetState($var[$i][0],"", @SW_RESTORE) EndIf EndIf Next Func IsVisible($handle) If BitAND(WinGetState($handle), 2) Then Return 1 Else Return 0 EndIf EndFunc ;==>IsVisible but i still dont understand why when i use winsetstate with program class and with @SW_SHOW or @SW_RESTORE my chrome doesn't maximize, im using windows 7 x64 and i saw, in a post, someone that could so... (btw i have chrome fixed where the programs icons appear when opened) If u could help me i would apreciate EvilRubberDuck
l3ill Posted November 16, 2013 Posted November 16, 2013 Hi EvilRubberDuck, I think I got lost somewhere in the translation :-) Where did we go from Speaker settings to Google Chrome? No Matter, here is an example of how to get the handle of a window. Once you have the handle you can boss it around all you like Run("notepad.exe") WinWaitActive("Untitled - Notepad") Send("This will be window nr. 1") Local $handle1 = WinGetHandle("[CLASS:Notepad]", "This will be window nr. 1") WinMove($handle1, "", 0, 0, 370, 370, 5) Bill My Contributions... SnippetBrowser NewSciTE PathFinder Text File Manipulation FTP Connection Tester / INI File - Read, Write, Save & Load Example
KaFu Posted November 16, 2013 Posted November 16, 2013 Take a look at SSD linked in my signature. OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16)
EvilRubberDuck Posted November 16, 2013 Author Posted November 16, 2013 Bill, thank your for your reply it help me understand better winmove command but still i have to ask something. I did this to your code: Run("notepad.exe") WinWaitActive("[CLASS:Notepad]") Local $handle1 = WinGetHandle("[CLASS:Notepad]", "") WinMove($handle1, "", 0, 0, 370, 370, 5) and it still works, so my question is why doesnt this code work: Run("notepad.exe") WinWaitActive("[CLASS:Notepad]") ; Center Window on Screen ; Author cdkid and Valuater Local $win=WinGetHandle("[CLASS:Notepad]", "") Func _Middle($win) $size = WinGetClientSize($win) Local $y = (@DesktopHeight / 2) - ($size[1] / 2) Local $x = (@DesktopWidth / 2) - ($size[0] / 2) Return WinMove($win, "", $x, $y) EndFunc ;==>_Middle about chrome is a completely diferent question xD Kafu, thank you also for replying, if i could understand right your program enables me to change my default audio device, with a specific command in a autoit code?
UEZ Posted November 16, 2013 Posted November 16, 2013 EvilRubberDuck, when you don't call the function it will never work! Run("notepad.exe") WinWaitActive("[CLASS:Notepad]") ; Center Window on Screen ; Author cdkid and Valuater _Middle(WinGetHandle("[CLASS:Notepad]", "")) Func _Middle($win) ;shortened Local $size = WinGetClientSize($win) Return WinMove($win, "", (@DesktopWidth - $size[0]) / 2, (@DesktopHeight - $size[1]) / 2) EndFunc ;==>_Middle Br, UEZ 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!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ
EvilRubberDuck Posted November 16, 2013 Author Posted November 16, 2013 LOOOOOOOL completely forgot about that xD Thank you UEZ
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