gte Posted December 29, 2009 Posted December 29, 2009 I feel like this should be easy, but I've had a hell of a time trying to figure out how to assign a variable to the output of wingetpos. I searched for about an hour and couldn't find anything conclusive. This code isn't correct, but I'd like to have it setup to something like the following $winpos = WinGetPos("HP OpenView ServiceCenter - Incident Queue:", "Open Incidents Assigned To My Branch") $winposhorizontal = $winpos[0] Thanks for reading. HP OpenView ServiceCenter keep alive scriptRemote Desktop Login Script
Kiti Posted December 29, 2009 Posted December 29, 2009 I feel like this should be easy, but I've had a hell of a time trying to figure out how to assign a variable to the output of wingetpos. I searched for about an hour and couldn't find anything conclusive. This code isn't correct, but I'd like to have it setup to something like the following $winpos = WinGetPos("HP OpenView ServiceCenter - Incident Queue:", "Open Incidents Assigned To My Branch") $winposhorizontal = $winpos[0] Thanks for reading. That's perfect, but just get rid of the second quotes in WinGetPos. Try this: $winpos = WinGetPos("HP OpenView ServiceCenter - Incident Queue:", "") $winposhorizontal = $winpos[0] $winposvertical = $winpos[1] MsgBox(0, "", $winposhorizontal & ":" & $winposvertical) It's working! Think outside the box.My Cool Lego Technic Website -- see walking bipeds and much more!My YouTube account -- see cool physics experimentsMy scripts:Minesweeper bot: Solves advanced level in 1 second (no registry edit), very improved GUI, 4 solving stylesCan't go to the toilet because of your kids closing your unsaved important work? - Make a specific window uncloseableCock Shooter Bot -- 30 headshots out of 30
Moderators Melba23 Posted December 29, 2009 Moderators Posted December 29, 2009 gte,There is nothing wrong with your syntax. What error do you get? Are you sure the 2 quotes are correct? Check with the Au3Info tool. If they are not correct then WinGetPos will fail and you do not have an array to access. Try something like this to check on that:$winpos = WinGetPos("HP OpenView ServiceCenter - Incident Queue:", "Open Incidents Assigned To My Branch") If Not IsArray($winpos) Then MsgBox(0, "Error", "No position found") $winposhorizontal = $winpos[0]Looking forward to the next instalment. 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
gte Posted December 29, 2009 Author Posted December 29, 2009 (edited) Thanks Melba/Kiti Here is the error message I'm getting C:\Documents and Settings\668692\My Documents\Work Stuff\AutoIt\testing\caprs2testing.au3 (394) : ==> Subscript used with non-Array variable.: $winposhorizontal = $winpos[0] $winposhorizontal = $winpos^ ERROR And the function Func _verifywinposition() Global $SM_VIRTUALWIDTH = 78 $VirtualDesktopWidth = DLLCall("user32.dll", "int", "GetSystemMetrics", "int", $SM_VIRTUALWIDTH) $VirtualDesktopWidth = $VirtualDesktopWidth[0] If WinExists("HP OpenView ServiceCenter - Incident Queue:", "Open Incidents Assigned To My Branch") Then $winpos = WinGetPos("HP OpenView ServiceCenter - Incident Queue:", "Open Incidents Assigned To My Branch") $winposhorizontal = $winpos[0] If $winposhorizontal >= ($VirtualDesktopWidth - 250) Then WinMove("HP OpenView ServiceCenter - Incident Queue:", "", $caprswindowlocation[0], $caprswindowlocation[1]) ConsoleWrite("Had to reset window position location to 500 less than " & $VirtualDesktopWidth & @CRLF) EndIf EndIf EndFunc That's perfect, but just get rid of the second quotes in WinGetPos. Try this: $winpos = WinGetPos("HP OpenView ServiceCenter - Incident Queue:", "") $winposhorizontal = $winpos[0] $winposvertical = $winpos[1] MsgBox(0, "", $winposhorizontal & ":" & $winposvertical) It's working! gte, There is nothing wrong with your syntax. What error do you get? Are you sure the 2 quotes are correct? Check with the Au3Info tool. If they are not correct then WinGetPos will fail and you do not have an array to access. Try something like this to check on that: $winpos = WinGetPos("HP OpenView ServiceCenter - Incident Queue:", "Open Incidents Assigned To My Branch") If Not IsArray($winpos) Then MsgBox(0, "Error", "No position found") $winposhorizontal = $winpos[0] Looking forward to the next instalment. M23 Edited December 29, 2009 by gte HP OpenView ServiceCenter keep alive scriptRemote Desktop Login Script
gte Posted December 29, 2009 Author Posted December 29, 2009 Edit That if statement that I threw in there to verify the window was present, made it work, I thought wingetpos would ignore the window request if it wasn't there, but I was wrong apparently HP OpenView ServiceCenter keep alive scriptRemote Desktop Login Script
Moderators Melba23 Posted December 29, 2009 Moderators Posted December 29, 2009 (edited) gte,That error is telling you that $winpos is not an array, as I suspected. So we can safely say that WinGetPos is not finding your window.Have you checked the 2 quotes you use to identify the window with the Au3Info tool yet? If you get those wrong, it will never work! M23Edit: OK, I see from your edit that you have solved it by checking if the window exists. Good idea! Edited December 29, 2009 by Melba23 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
gte Posted December 29, 2009 Author Posted December 29, 2009 Yes, you were right as usual Melba Thanks again for the guidance, I think this script is finally ready to go!gte,That error is telling you that $winpos is not an array, as I suspected. So we can safely say that WinGetPos is not finding your window.Have you checked the 2 quotes you use to identify the window with the Au3Info tool yet? If you get those wrong, it will never work! M23Edit: OK, I see from your edit that you have solved it by checking if the window exists. Good idea! HP OpenView ServiceCenter keep alive scriptRemote Desktop Login Script
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