mikejson Posted December 21, 2011 Share Posted December 21, 2011 HI folks, New to the forums, and AutoIt scripting... I have looked at the Wiki documentation and thought I knew what I was doing, but I think I need a push in the right direction. I'm attempting to make a script that when a button I define is pressed will minimize and hide a specific window, and when I hit another button it'll restore and show that window again. I believe my script is failing when attempting to get the window handle. I've tried by WinGetHandle and using the name, but I think that is the part that is failing. So a few questions that I have: - is there a way to "test" the WinGetHandle? Does it throw an error that you can catch? This may give me more troubleshooting avenues... - I've been trying to grab the handle by name but if there is a way to grab the handle of the last window in focus before I hit the key I assign to start the script, that would work for what I'm trying to do. is there something I can use to get the last window in focus? - Is there a different way to get the handle of a window depending on the program itself(besides just the name)? This may give me more information that I can go google. Any answers to those 3 questions may give me some more leads to dig to the answer... although, if someone wants to attempt to provide the complete answer, that is also appreciated! Thanks! Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted December 21, 2011 Moderators Share Posted December 21, 2011 (edited) Hi, Mikejson. Welcome to the forums. To answer your first question, you can check what the handle will be by assigning it to a variable and then piping it to the output of your choice. Below is a very simple example. $var = WinGetHandle("Untitled - Notepad") MsgBox(0, "", $var) You could then double check by trying to send text to the window... ControlSend($var, "", "Edit1", "1234") Edited December 21, 2011 by JLogan3o13 "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
Skitty Posted December 21, 2011 Share Posted December 21, 2011 use a script like one to see if you have the right name first? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 21, 2011 Moderators Share Posted December 21, 2011 mikejson, You can get the handle of the currently active window like this: ConsoleWrite(WinGetHandle("[ACTIVE]") & @CRLF) ConsoleWrite(WinGetHandle("[CLASS:SciTEWindow]") & @CRLF) Run it from within SciTE and you will see you get the same values returned. 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...
mikejson Posted December 22, 2011 Author Share Posted December 22, 2011 HI everyone, So I now have my script getting the active window(as a note, you can just use WinGetHandle(""), but I did try the [ACTIVE] and it worked as well). I still have an issue, and I think it may be related to the limitations of AutoIt... not sure. I'm trying to build this script so that I can minimize and hide a game while I'm at work haha.... but it isn't picking up the handle of my game. The game is in window mode, so I would think it'd be able to grab it like any other window... Here is the code I have for testing Global $Show = 0 Global $handle = WinGetHandle("[ACTIVE]") Global $name = WinGetTitle("[ACTIVE]") MsgBox(0,"Handle",$handle) MsgBox(0,"Name",$name) On any other window, my message boxes show up with the relevant information. When I have my game as the active window and hit the button that runs the above code, it just doesn't do anything. Any thoughts? Link to comment Share on other sites More sharing options...
mikejson Posted December 22, 2011 Author Share Posted December 22, 2011 So I thought of another test to do. I put a MsgBox just above the WinGetHandle line... just to see if the script was even getting the key press I was doing. It wasn't... Something is blocking the keypress from getting to AutoIt to even start the script. I guess I could take the keypress out of the equation somehow... but I'm wondering if anyone has run into this and figured out how to fix the issue... Thanks! Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 22, 2011 Moderators Share Posted December 22, 2011 mikejson,I'm trying to build this script so that I can minimize and hide a gamePlease read the Forum Rules now and then you will understand why you will get no more help and this thread is locked. And make sure you read the part about creating new topics on locked subjects. 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