AutoDEV Posted November 13, 2023 Share Posted November 13, 2023 Hello When my soft begin i ajust a size of windows program. But how to check every time if is changed ? THX Link to comment Share on other sites More sharing options...
Andreik Posted November 13, 2023 Share Posted November 13, 2023 (edited) This could be a simple way: AutoItSetOption('WinTitleMatchMode', 2) HotKeySet('{ESC}', 'Quit') ; Press ESC to exit the script Local $aPos[4], $aNewPos[4] Run('notepad.exe') WinWait('Notepad') $aPos = WinGetPos('Notepad') MsgBox(0, '', 'Press OK and then resize the Notepad window' & @CRLF & 'Check what''s happening in the console') While True $aNewPos = WinGetPos('Notepad') If $aPos[2] <> $aNewPos[2] Or $aPos[3] <> $aNewPos[3] Then $aPos = $aNewPos ConsoleWrite('Window has been resized (New size: ' & $aPos[2] & 'x' & $aPos[3] & ').' & @CRLF) EndIf Sleep(10) WEnd Func Quit() Exit EndFunc If it's a window created by you, another way is to register WM_SIZING that is sent to a window after its size has changed. Edited November 13, 2023 by Andreik When the words fail... music speaks. Link to comment Share on other sites More sharing options...
AutoDEV Posted November 13, 2023 Author Share Posted November 13, 2023 (edited) THX it's working. Now, if program change position how can i make for detect Edited November 13, 2023 by AutoDEV Link to comment Share on other sites More sharing options...
Andreik Posted November 13, 2023 Share Posted November 13, 2023 Position it's holded in index 0 and index 1 of $aPos and $aNewPos. Basically it's the same example but with index 2 and index 3 replaced by new indices 0 and 1. When the words fail... music speaks. Link to comment Share on other sites More sharing options...
AutoDEV Posted November 13, 2023 Author Share Posted November 13, 2023 (edited) ok, ihave make this : expandcollapse popupAutoItSetOption('WinTitleMatchMode', 2) HotKeySet('{ESC}', 'Quit') ; Press ESC to exit the script Local $aPos[4], $aNewPos[4] Run('notepad.exe') WinWait('Sans titre - Bloc-notes') $aPos = WinGetPos('Sans titre - Bloc-notes') MsgBox(0, '', 'Position = ' & $aPos[0] & '/' & $aPos[1]) While True $aNewPos = WinGetPos('Sans titre - Bloc-notes') Global $notepad = WinList("Sans titre - Bloc-notes") If $aNewPos <> 0 Then If $aPos[0] <> $aNewPos[0] Or $aPos[1] <> $aNewPos[1] Then $aPos = $aNewPos Global $windows = WinMove($notepad[1][0], "", 0, 0, 1024, 768) ConsoleWrite('Window has been resized (New pos: ' & $aPos[0] & 'x' & $aPos[1] & ').' & @CRLF) EndIf Sleep(10) EndIf WEnd MsgBox(0, '', 'Press OK and then resize the Notepad window' & @CRLF & 'Check what''s happening in the console') While True $aNewPos = WinGetPos('Sans titre - Bloc-notes') If $aPos[2] <> $aNewPos[2] Or $aPos[3] <> $aNewPos[3] Then Global $notepad = WinList("Sans titre - Bloc-notes") If $aNewPos <> 0 Then $aPos = $aNewPos Global $windows = WinMove($notepad[1][0], "", 0, 0, 1024, 768 ConsoleWrite('Window has been resized (New size: ' & $aPos[2] & 'x' & $aPos[3] & ').' & @CRLF) EndIf Sleep(10) EndIf WEnd Func Quit() Exit EndFunc But i think a code is big for check pos and size. Edited November 13, 2023 by AutoDEV Link to comment Share on other sites More sharing options...
Andreik Posted November 13, 2023 Share Posted November 13, 2023 Try this: AutoItSetOption('WinTitleMatchMode', 2) Local $aPos[4], $aNewPos[4] Run('notepad.exe') WinWait('Notepad') $aPos = WinGetPos('Notepad') MsgBox(0, '', 'Press OK and then resize or move the Notepad window' & @CRLF & 'Check what''s happening in the console') While WinExists('Notepad') $aNewPos = WinGetPos('Notepad') If $aPos[0] <> $aNewPos[0] Or $aPos[1] <> $aNewPos[1] Then $aPos = $aNewPos ConsoleWrite('Window has been repositioned (New position: ' & $aPos[0] & 'x' & $aPos[1] & ').' & @CRLF) EndIf If $aPos[2] <> $aNewPos[2] Or $aPos[3] <> $aNewPos[3] Then $aPos = $aNewPos ConsoleWrite('Window has been resized (New size: ' & $aPos[2] & 'x' & $aPos[3] & ').' & @CRLF) EndIf Sleep(10) WEnd When the words fail... music speaks. Link to comment Share on other sites More sharing options...
AutoDEV Posted November 14, 2023 Author Share Posted November 14, 2023 THX. I have one problem. My script not continue to work and wait a windows change pos and size. How to exit loop and continue to checking my windows (notetpad) Plz Link to comment Share on other sites More sharing options...
Andreik Posted November 14, 2023 Share Posted November 14, 2023 10 minutes ago, AutoDEV said: My script not continue to work and wait a windows change pos and size. What is your script actually? Post your code. When the words fail... music speaks. Link to comment Share on other sites More sharing options...
AutoDEV Posted November 14, 2023 Author Share Posted November 14, 2023 expandcollapse popupAutoItSetOption('WinTitleMatchMode', 2) Local $aPos[4], $aNewPos[4] Run('notepad.exe') WinWait('Sans titre - Bloc-notes') $aPos = WinGetPos('Sans titre - Bloc-notes') MsgBox(0, '', 'Press OK and then resize or move the Notepad window' & @CRLF & 'Check what''s happening in the console') While WinExists('Sans titre - Bloc-notes') $aNewPos = WinGetPos('Sans titre - Bloc-notes') If $aPos[0] <> $aNewPos[0] Or $aPos[1] <> $aNewPos[1] Then $aPos = $aNewPos ConsoleWrite('Window has been repositioned (New position: ' & $aPos[0] & 'x' & $aPos[1] & ').' & @CRLF) EndIf If $aPos[2] <> $aNewPos[2] Or $aPos[3] <> $aNewPos[3] Then $aPos = $aNewPos ConsoleWrite('Window has been resized (New size: ' & $aPos[2] & 'x' & $aPos[3] & ').' & @CRLF) EndIf Sleep(10) WEnd Func Example2() Local $sFilePath = _WinAPI_GetTempFileName(@TempDir) Local $hDownload = InetGet("http://mywebsite.com/download/updates.txt", $sFilePath) Global $remoteVersion1 = IniReadSection($sFilePath, 'Update') If Not @error Then For $i = 1 To $remoteVersion1[0][0] Switch $remoteVersion1[$i][0] Case "ProductVersion" Global $rVersion = $remoteVersion1[$i][1] MsgBox(0, 'remoteversion', $rVersion) EndSwitch Next Global $localVersion = FileGetVersion('myprog.exe') ConsoleWrite(@AutoItExe) MsgBox(0, 'version Local', $localVersion) If $rVersion > $localVersion Then MsgBox(0, 'version', 'Update Avaibale') EndIf EndIf EndFunc Example2() Link to comment Share on other sites More sharing options...
Andreik Posted November 14, 2023 Share Posted November 14, 2023 I don't get the logic of your script. What it's suppose to do? When the words fail... music speaks. Link to comment Share on other sites More sharing options...
AutoDEV Posted November 14, 2023 Author Share Posted November 14, 2023 (edited) OK. First i start notepad and i check id is changed. Exemple2() check remote version of program and compare with local. But for continue script i need close notepad. I want check every time pos and size of notepad and not block a script in this loop. How to make plz ? Edited November 14, 2023 by AutoDEV Link to comment Share on other sites More sharing options...
Andreik Posted November 14, 2023 Share Posted November 14, 2023 I still don't get it. What's the point of checking if the position or the size of notepad has changed with the code from Example2()? You can call Example2() anywhere between While and Wend if you want to keep calling this function but I don't see the point. This code makes no sense. When the words fail... music speaks. Link to comment Share on other sites More sharing options...
AutoDEV Posted November 14, 2023 Author Share Posted November 14, 2023 (edited) For a script is not nimportant to know code. Just while block code, and not continue. For continue a script i need close notepad. I have try with exitloop but after my notepad close but code continuous and work Quote While WinExists('Sans titre - Bloc-notes') $aNewPos = WinGetPos('Sans titre - Bloc-notes') If $aPos[0] <> $aNewPos[0] Or $aPos[1] <> $aNewPos[1] Then $aPos = $aNewPos ConsoleWrite('Window has been repositioned (New position: ' & $aPos[0] & 'x' & $aPos[1] & ').' & @CRLF) ExitLoop EndIf If $aPos[2] <> $aNewPos[2] Or $aPos[3] <> $aNewPos[3] Then $aPos = $aNewPos ConsoleWrite('Window has been resized (New size: ' & $aPos[2] & 'x' & $aPos[3] & ').' & @CRLF) ExitLoop EndIf Sleep(10) WEnd Edited November 14, 2023 by AutoDEV Link to comment Share on other sites More sharing options...
AutoDEV Posted November 14, 2023 Author Share Posted November 14, 2023 (edited) I have cretae exemple. Look, when i add loop while, all is not working I have same problem with my app expandcollapse popup#Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 195, 47, 192, 124, BitOR($WS_SIZEBOX, $WS_SYSMENU)) $Button1 = GUICtrlCreateButton("OK", 16, 8, 75, 25) $Button2 = GUICtrlCreateButton("CANCEL", 104, 8, 75, 25) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### AutoItSetOption('WinTitleMatchMode', 2) Local $aPos[4], $aNewPos[4] $aPos = WinGetPos($Form1) While WinExists('Form1') $aNewPos = WinGetPos($form1) If $aPos[0] <> $aNewPos[0] Or $aPos[1] <> $aNewPos[1] Then $aPos = $aNewPos ConsoleWrite('Window has been repositioned (New position: ' & $aPos[0] & 'x' & $aPos[1] & ').' & @CRLF) EndIf If $aPos[2] <> $aNewPos[2] Or $aPos[3] <> $aNewPos[3] Then $aPos = $aNewPos ConsoleWrite('Window has been resized (New size: ' & $aPos[2] & 'x' & $aPos[3] & ').' & @CRLF) EndIf Sleep(10) WEnd While $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 MsgBox(0, '', 'Button OK is pressed') Case $Button2 MsgBox(0, '', 'Button CANCEL is presses') EndSwitch WEnd Edited November 14, 2023 by AutoDEV Link to comment Share on other sites More sharing options...
Andreik Posted November 14, 2023 Share Posted November 14, 2023 All I can see it's that you post code that it doesn't even run. #include <WindowsConstants.au3> #include <GUIConstants.au3> Global $aPos[4], $aNewPos[4] $Form1 = GUICreate("Form1", 195, 100, 192, 150, BitOR($WS_SIZEBOX, $WS_SYSMENU)) $Button1 = GUICtrlCreateButton("OK", 16, 8, 75, 25) $Button2 = GUICtrlCreateButton("CANCEL", 104, 8, 75, 25) GUISetState(@SW_SHOW) While True Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $Button1 MsgBox(0, '', 'Button OK is pressed') Case $Button2 MsgBox(0, '', 'Button CANCEL is presses') EndSwitch $aNewPos = WinGetPos($form1) If $aPos[0] <> $aNewPos[0] Or $aPos[1] <> $aNewPos[1] Then $aPos = $aNewPos ConsoleWrite('Window has been repositioned (New position: ' & $aPos[0] & 'x' & $aPos[1] & ').' & @CRLF) EndIf If $aPos[2] <> $aNewPos[2] Or $aPos[3] <> $aNewPos[3] Then $aPos = $aNewPos ConsoleWrite('Window has been resized (New size: ' & $aPos[2] & 'x' & $aPos[3] & ').' & @CRLF) EndIf WEnd When the words fail... music speaks. Link to comment Share on other sites More sharing options...
AutoDEV Posted November 15, 2023 Author Share Posted November 15, 2023 (edited) OK it's working But why this code not working ? #include <WindowsConstants.au3> #include <GUIConstants.au3> Func _checkChangeWindows() Global $aPos[4], $aNewPos[4] Global $fenetre = WinList("Sans titre - Bloc-notes") WinWait('Sans titre - Bloc-notes') $aPos = WinGetPos('Sans titre - Bloc-notes') MsgBox(0, '', 'Position = ' & $aPos[0] & '/' & $aPos[1]) While True $aNewPos = WinGetPos($fenetre) If $aPos[0] <> $aNewPos[0] Or $aPos[1] <> $aNewPos[1] Then $aPos = $aNewPos ConsoleWrite('Window has been repositioned (New position: ' & $aPos[0] & 'x' & $aPos[1] & ').' & @CRLF) EndIf If $aPos[2] <> $aNewPos[2] Or $aPos[3] <> $aNewPos[3] Then $aPos = $aNewPos ConsoleWrite('Window has been resized (New size: ' & $aPos[2] & 'x' & $aPos[3] & ').' & @CRLF) EndIf WEnd EndFunc I have add code, for debug all is ok. But all after this script not working, exemple inpuit not working Pelase help me. Edited November 15, 2023 by AutoDEV Link to comment Share on other sites More sharing options...
Andreik Posted November 15, 2023 Share Posted November 15, 2023 Because whatever goes between Func and EndFunc is the body of a function and is not run until that function is called by name. #include <WindowsConstants.au3> #include <GUIConstants.au3> _checkChangeWindows() Func _checkChangeWindows() Global $aPos[4], $aNewPos[4] Global $fenetre = WinList("Sans titre - Bloc-notes") WinWait('Sans titre - Bloc-notes') $aPos = WinGetPos('Sans titre - Bloc-notes') MsgBox(0, '', 'Position = ' & $aPos[0] & '/' & $aPos[1]) While True $aNewPos = WinGetPos($fenetre) If $aPos[0] <> $aNewPos[0] Or $aPos[1] <> $aNewPos[1] Then $aPos = $aNewPos ConsoleWrite('Window has been repositioned (New position: ' & $aPos[0] & 'x' & $aPos[1] & ').' & @CRLF) EndIf If $aPos[2] <> $aNewPos[2] Or $aPos[3] <> $aNewPos[3] Then $aPos = $aNewPos ConsoleWrite('Window has been resized (New size: ' & $aPos[2] & 'x' & $aPos[3] & ').' & @CRLF) EndIf WEnd EndFunc When the words fail... music speaks. Link to comment Share on other sites More sharing options...
AutoDEV Posted November 15, 2023 Author Share Posted November 15, 2023 I called a function in my script. My code is : Func _checkChangeWindows() AutoItSetOption('WinTitleMatchMode', 2) Local $aPos[4], $aNewPos[4] Global $fenetre = WinList("[CLASS:Notepad]") WinActivate($fenetre[1][0]) WinSetState($fenetre[1][0],"",@SW_MINIMIZE) WinSetState($fenetre[1][0],"",@SW_RESTORE) Global $windows = WinMove($fenetre[1][0], "", 0, 0, 1024, 768) $aPos = WinGetPos($fenetre[1][0]) MsgBox(0, '', $aPos[0] & '/' & $aPos[1]) While WinExists("[CLASS:Notepad]") $aNewPos = WinGetPos("[CLASS:Notepad]") If $aPos[0] <> $aNewPos[0] Or $aPos[1] <> $aNewPos[1] Then $aPos = $aNewPos ConsoleWrite('Window has been repositioned (New position: ' & $aPos[0] & 'x' & $aPos[1] & ').' & @CRLF) EndIf If $aPos[2] <> $aNewPos[2] Or $aPos[3] <> $aNewPos[3] Then $aPos = $aNewPos ConsoleWrite('Window has been resized (New size: ' & $aPos[2] & 'x' & $aPos[3] & ').' & @CRLF) EndIf Sleep(10) WEnd EndFunc And again any button in my form working. and script is blocked waiting Link to comment Share on other sites More sharing options...
AutoDEV Posted December 2, 2023 Author Share Posted December 2, 2023 hello. I have short exemple. $choice = GUICreate("Custom MsgBox", 225, 80) GUICtrlCreateLabel("Please select a button.", 10, 10) Local $idYess = GUICtrlCreateButton("YES", 10, 50, 65, 25) Local $idNoo = GUICtrlCreateButton("NON", 80, 50, 65, 25) Local $idExitt = GUICtrlCreateButton("EXIT", 150, 50, 65, 25) GUISetState(@SW_SHOW, $choice) ;While can must run in background While 1 Switch GUIGetMsg() Case $idYess ConsoleWrite("$idYess=" & $idYess & @CRLF) ;ExitLoop Case $idNoo ConsoleWrite("$idNoo=" & $idNoo & @CRLF) EndSwitch WEnd MsgBox(0, '', "I want show this msgbox") Please can you tell me how to continue and not stay in loop while ? For whow show a MsgBox Is very imposrtant, im try hard without success. It's my last topic, and if i not success i stop my project. Thank you Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 2, 2023 Moderators Share Posted December 2, 2023 AutoDEV, $choice = GUICreate("Custom MsgBox", 225, 80) GUICtrlCreateLabel("Please select a button.", 10, 10) Local $idYess = GUICtrlCreateButton("YES", 10, 50, 65, 25) Local $idNoo = GUICtrlCreateButton("NON", 80, 50, 65, 25) Local $idExitt = GUICtrlCreateButton("EXIT", 150, 50, 65, 25) GUISetState(@SW_SHOW, $choice) ;While can must run in background While 1 Switch GUIGetMsg() Case $idExitt ExitLoop ; or just Exit if you want to leave the script without showing the MsgBox Case $idYess ConsoleWrite("$idYess=" & $idYess & @CRLF) ExitLoop Case $idNoo ConsoleWrite("$idNoo=" & $idNoo & @CRLF) ExitLoop EndSwitch WEnd MsgBox(0, '', "I want show this msgbox") M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area 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