Jump to content

Recommended Posts

Posted

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!

  • Moderators
Posted (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 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!

  • Moderators
Posted

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Posted

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?

Posted

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!

  • Moderators
Posted

mikejson,

I'm trying to build this script so that I can minimize and hide a game

Please 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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...