Jump to content

Window Hider


Shade
 Share

Recommended Posts

Glad it works now!

Regards

Don't take my pic to serious...~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~You Looked, but you did not see!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Link to comment
Share on other sites

Hey, I'm pretty new to AutoIt. I wrote this script that hides a window and then shows it again. Check it out, tell me what you think. :)

Shade,

I hope you don't mind, but I took some liberties with your script to make it hide upto five windows.

taurus905

; WinHider5.au3
; Original script by Shade
; Multiple windows idea by Firestorm
; Edited by taurus905
; Hides upto 5 windows by using CTRL-Shift-1 through CTRL-Shift-5
; Show hidden window by using ALT-Shift-1 through ALT-Shift-5
; http://www.autoitscript.com/forum/index.php?showtopic=26859&st=0
HotKeySet ("^+1", "Hide1"); CTRL-SHIFT-1
HotKeySet ("!+1", "Show1"); ALT-SHIFT-1
HotKeySet ("^+2", "Hide2"); CTRL-SHIFT-2
HotKeySet ("!+2", "Show2"); ALT-SHIFT-2
HotKeySet ("^+3", "Hide3"); CTRL-SHIFT-3
HotKeySet ("!+3", "Show3"); ALT-SHIFT-3
HotKeySet ("^+4", "Hide4"); CTRL-SHIFT-4
HotKeySet ("!+4", "Show4"); ALT-SHIFT-4
HotKeySet ("^+5", "Hide5"); CTRL-SHIFT-5
HotKeySet ("!+5", "Show5"); ALT-SHIFT-5

Opt("TrayIconHide", 1)

$hidden1 = "no"
$hidden2 = "no"
$hidden3 = "no"
$hidden4 = "no"
$hidden5 = "no"

While 1
    If $hidden1 = "yes" Then
        Sleep (10)
    Else
        Global $title1 = WinGetTitle("")
        Sleep (10)
    EndIf

    If $hidden2 = "yes" Then
        Sleep(10)
    Else
        Global $title2 = WinGetTitle("")
        Sleep(10)
    EndIf

    If $hidden3 = "yes" Then
        Sleep(10)
    Else
        Global $title3 = WinGetTitle("")
        Sleep(10)
    EndIf

    If $hidden4 = "yes" Then
        Sleep(10)
    Else
        Global $title4 = WinGetTitle("")
        Sleep(10)
    EndIf

    If $hidden5 = "yes" Then
        Sleep(10)
    Else
        Global $title5 = WinGetTitle("")
        Sleep(10)
    EndIf
WEnd

Func Hide1()
    If WinExists($title1) Then
        WinSetState ($title1, "", @SW_Hide)
        If $hidden1 = "no" Then FocusRight()
    EndIf
    $hidden1 = "yes"
EndFunc

Func Show1()
    If WinExists( $title1) Then
        WinSetState ($title1 , "", @SW_SHOW)
        If $hidden1 = "yes" Then FocusLeft()
    EndIf
    $hidden1 = "no"
EndFunc

Func Hide2()
    If WinExists($title2) Then
        WinSetState ($title2, "", @SW_Hide)
        If $hidden2 = "no" Then FocusRight()
    EndIf
    $hidden2 = "yes"
EndFunc

Func Show2()
    If WinExists($title2) Then
        WinSetState ($title2 ,"", @SW_Show)
        If $hidden2 = "yes" Then FocusLeft()
    EndIf
    $hidden2 = "no"
EndFunc

Func Hide3()
    If WinExists($title3) Then
        WinSetState ($title3, "", @SW_Hide)
        If $hidden3 = "no" Then FocusRight()
    EndIf
    $hidden3 = "yes"
EndFunc

Func Show3()
    If WinExists($title3) Then
        WinSetState ($title3 ,"", @SW_Show)
        If $hidden3 = "yes" Then FocusLeft()
    EndIf
    $hidden3 = "no"
EndFunc

Func Hide4()
    If WinExists($title4) Then
        WinSetState ($title4, "", @SW_Hide)
        If $hidden4 = "no" Then FocusRight()
    EndIf
    $hidden4 = "yes"
EndFunc

Func Show4()
    If WinExists($title4) Then
        WinSetState ($title4 ,"", @SW_Show)
        If $hidden4 = "yes" Then FocusLeft()
    EndIf
    $hidden4 = "no"
EndFunc

Func Hide5()
    If WinExists($title5) Then
        WinSetState ($title5, "", @SW_Hide)
        If $hidden5 = "no" Then FocusRight()
    EndIf
    $hidden5 = "yes"
EndFunc

Func Show5()
    If WinExists($title5) Then
        WinSetState ($title5 ,"", @SW_Show)
        If $hidden5 = "yes" Then FocusLeft()
    EndIf
    $hidden5 = "no"
EndFunc

Func FocusRight()
    Send("{ALTDOWN}")
    Send("{TAB}")
    Send("{ALTUP}")
EndFunc

Func FocusLeft()
    Send("{ALTDOWN}")
    Send("+{TAB}")
    Send("{ALTUP}")
EndFunc

"Never mistake kindness for weakness."-- Author Unknown --"The highest point to which a weak but experienced mind can rise is detecting the weakness of better men."-- Georg Lichtenberg --Simple Obfuscator (Beta not needed.), Random names for Vars and Funcs

Link to comment
Share on other sites

  • Moderators

This seems to give the desired affect as well:

#NoTrayIcon

HotKeySet ("^+1", "_Set1"); CTRL-SHIFT-1
HotKeySet ("^+2", "_Set2"); CTRL-SHIFT-2
HotKeySet ("^+3", "_Set3"); CTRL-SHIFT-3
HotKeySet ("^+4", "_Set4"); CTRL-SHIFT-4
HotKeySet ("^+5", "_Set5"); CTRL-SHIFT-5

Global $HideMe[6]
For $i = 1 To 5
    $HideMe[$i] = False
Next

Global $WinTitle[6]

While 1
    Sleep(100)
WEnd

Func _Set1()
    If $HideMe[1] = False Then
        $WinTitle[1] = WinGetTitle('')
        _Hide_Show(1)
    Else
        _Hide_Show(1)
    EndIf
EndFunc

Func _Set2()
    If $HideMe[2] = False Then
        $WinTitle[2] = WinGetTitle('')
        _Hide_Show(2)
    Else
        _Hide_Show(2)
    EndIf
EndFunc

Func _Set3()
    If $HideMe[3] = False Then
        $WinTitle[3] = WinGetTitle('')
        _Hide_Show(3)
    Else
        _Hide_Show(3)
    EndIf
EndFunc

Func _Set4()
    If $HideMe[4] = False Then
        $WinTitle[4] = WinGetTitle('')
        _Hide_Show(4)
    Else
        _Hide_Show(4)
    EndIf
EndFunc

Func _Set5()
    If $HideMe[5] = False Then
        $WinTitle[5] = WinGetTitle('')
        _Hide_Show(5)
    Else
        _Hide_Show(5)
    EndIf
EndFunc

Func _Hide_Show($iElement)
    If $HideMe[$iElement] = False Then
        WinSetState($WinTitle[$iElement], '', @SW_HIDE)
        $HideMe[$iElement] = True
    Else
        WinSetState($WinTitle[$iElement] , "", @SW_SHOW)
        $HideMe[$iElement] = False
        $WinTitle[$iElement] = ''
    EndIf
EndFunc
Needs beta for True/False ... replace with 1 / 0 if you don't want to use Beta.

Edit:

Should say I eliminated the need for 2 hotkeys... made sense to use the same one that you used to hide it to bring it back.

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

taurus and smoke, nice job on the modifications! It's really cool that we can all come together and make scripts better. :) I guess the limit would be 64 because of the HotKey limit. But who would need to hide that many windows anways.

Shade,

SmOke_N is a far better programmer than I will ever be. I learn something every time I look at one of his scripts and a large number of other users on this site.

The AutoIt Forum is a great place to learn and share. Welcome to our online community. :(

taurus905

"Never mistake kindness for weakness."-- Author Unknown --"The highest point to which a weak but experienced mind can rise is detecting the weakness of better men."-- Georg Lichtenberg --Simple Obfuscator (Beta not needed.), Random names for Vars and Funcs

Link to comment
Share on other sites

  • 2 years later...

Well hope you don't mind but you guys are just making this harder then it really is. Here is the way I would do it:

HotKeySet ("{F1}", "_Win1"); F1
HotKeySet ("{F2}", "_Win2"); F2
HotKeySet ("{F3}", "_Win3"); F3
HotKeySet ("{F4}", "_Win4"); F4
HotKeySet ("{F5}", "_Win5"); F5

Global $window

While 1
    Sleep(100)
WEnd

Func _Win1()
    $window = "no" 
    _ShowHide()
EndFunc

Func _Win2()
    $window = "no" 
    _ShowHide()
EndFunc

Func _Win3()
    $window = "no" 
    _ShowHide()
EndFunc

Func _Win4()
    $window = "no" 
    _ShowHide()
EndFunc

Func _Win5()
    $window = "no" 
    _ShowHide()
EndFunc

Func _ShowHide()
    Local $state = WinGetState($window, "")
    If BitAnd($state, 2) Then
        WinSetState($window, "", @SW_HIDE)
    Else
        WinSetState($window, "", @SW_SHOW)
    EndIf
EndFunc
Link to comment
Share on other sites

Here's a little something I whipped up in 20 mins with an Ini, GUI, can load up previous settings or just reconfig it, it handles 11 hotkeys, F1-F11

Oh, and sorry for the double post. Couldn't find the edit button for my post above, just thought u would let it slide since :)

#cs ----------------------------------------------------------------------------
    
    AutoIt Version: 3.2.13.2 Beta
    Author:      T_LOKZz
    
    Script Function:
    Hide Windows and Show them from a HotKey
    
#ce ----------------------------------------------------------------------------

#include <File.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Misc.au3>

HotKeySet ("{Esc}", "ExitProg"); Esc

$thisprogram = StringTrimRight(@ScriptName, 4)
If _Singleton($thisprogram, 1) = 0 Then
    MsgBox(4096, "Warning", "An occurence of " & $thisprogram & " is already running")
    Exit
EndIf

Opt("GUIOnEventMode", 1); this will make the buttons in the GUI call the functions we have set

Global $window, $winnumber, $numofwins, $winname, $Label3
$inidir = @ScriptDir & "\WinHider.ini"; Ini Dir
$logdir = @ScriptDir & "\WinHider.log"; Log Dir

If FileExists($logdir) Then
    FileDelete($logdir)
EndIf


If Not FileExists($inidir) Then; If it doesn't exist we want to create it
    _FileCreate($inidir)
    IntroScreen()
Else
    Local $lines = _FileCountLines($inidir)
    If $lines = 0 Then
        FileDelete($inidir)
        _FileCreate($inidir)
        IntroScreen()
    Else
        If Not IsDeclared("iMsgBoxAnswer") Then Local $iMsgBoxAnswer; load ini or create new one?
        $iMsgBoxAnswer = MsgBox(292,"WinHider","Would you like to use your last used WinHider config?")
        Select
            Case $iMsgBoxAnswer = 6;Yes
                _LoadHotKeys()
            Case $iMsgBoxAnswer = 7;No
                FileDelete($inidir)
                _FileCreate($inidir)
                IntroScreen()
        EndSelect
    EndIf
EndIf

Func IntroScreen(); Intro Screen :)
    $Form1 = GUICreate("WinHider", 203, 177, 193, 125)
    $Label1 = GUICtrlCreateLabel("WinHider", 34, 24, 127, 45)
    GUICtrlSetFont(-1, 22, 400, 0, "JanieHmkBold")
    $Label2 = GUICtrlCreateLabel("Number of Windows:", 33, 80, 130, 17)
    GUICtrlSetFont(-1, 10, 400, 0, "@DFKai-SB")
    $numofwins = GUICtrlCreateInput("", 75, 104, 33, 21)
    $Button1 = GUICtrlCreateButton("Ok", 128, 136, 35, 25, 0)
    GUICtrlSetOnEvent(-1, "IntroDone")
    GUISetState(@SW_SHOW)
    HotKeySet ("{Enter}", "IntroDone")
EndFunc

Func IntroDone(); Save the number of windows the user has inputed
    $winnumber = GUICtrlRead($numofwins)
    If $winnumber > 11 Then
        MsgBox(48,"WinHider","Incorrect number of windows. Supports 1 - 11")
    Else
        GUISetState(@SW_HIDE)
        _Next()
    EndIf
EndFunc

Func _Next(); GUI for the user to set each Windows name
    $Form1 = GUICreate("WinHider", 203, 177, 193, 125)
    $Label1 = GUICtrlCreateLabel("WinHider", 34, 24, 127, 45)
    GUICtrlSetFont(-1, 22, 400, 0, "JanieHmkBold")
    $Label2 = GUICtrlCreateLabel("Name of Window:", 33, 80, 109, 17)
    GUICtrlSetFont(-1, 10, 400, 0, "@DFKai-SB")
    $Label3 = GUICtrlCreateLabel("1", 144, 80, 16, 17)
    $winname = GUICtrlCreateInput("", 14, 104, 175, 21)
    $Button1 = GUICtrlCreateButton("Ok", 128, 136, 35, 25, 0)
    GUICtrlSetOnEvent(-1, "WindowSave")
    GUISetState(@SW_SHOW)
    HotKeySet ("{Enter}", "WindowSave")
EndFunc

Func WindowSave(); Save the user data and go to the next window, if any
    Local $tempnum = GUICtrlRead($Label3)
    IniWrite ($inidir, "Window Titles", "Window" & $tempnum, GUICtrlRead($winname))
    If $tempnum < $winnumber Then; will only set the number of window names for as many as the user inputed on the introscreen
        $tempnum = $tempnum + 1
        GUICtrlSetData($Label3, $tempnum)
    Else
        _LoadHotKeys()
    EndIf
EndFunc

Func _LoadHotKeys() 
    HotKeySet ("{F1}", "_Win1"); F1
    HotKeySet ("{F2}", "_Win2"); F2
    HotKeySet ("{F3}", "_Win3"); F3
    HotKeySet ("{F4}", "_Win4"); F4
    HotKeySet ("{F5}", "_Win5"); F5
    HotKeySet ("{F6}", "_Win6"); F6
    HotKeySet ("{F7}", "_Win7"); F7
    HotKeySet ("{F8}", "_Win8"); F8
    HotKeySet ("{F9}", "_Win9"); F9
    HotKeySet ("{F10}", "_Win10"); F10
    HotKeySet ("{F11}", "_Win11"); F11
EndFunc 

While 1; must have this to just wait around for the hotkeys to be pressed
    Sleep(100)
WEnd

Func _Win1()
    $window = IniRead($inidir, "Window Titles", "Window1", ""); Read the Window Name from Ini
    _FileWriteLog($logdir, "Info: F1 pressed and Window: " & $window & " was hidden/shown."); write the action to the log 
    _ShowHide()
EndFunc

Func _Win2()
    $window = IniRead($inidir, "Window Titles", "Window2", "")
    _FileWriteLog($logdir, "Info: F2 pressed and Window: " & $window & " was hidden/shown.")
    _ShowHide()
EndFunc

Func _Win3()
    $window = IniRead($inidir, "Window Titles", "Window3", "")
    _FileWriteLog($logdir, "Info: F3 pressed and Window: " & $window & " was hidden/shown.")
    _ShowHide()
EndFunc

Func _Win4()
    $window = IniRead($inidir, "Window Titles", "Window4", "")
    _FileWriteLog($logdir, "Info: F4 pressed and Window: " & $window & " was hidden/shown.")
    _ShowHide()
EndFunc

Func _Win5()
    $window = IniRead($inidir, "Window Titles", "Window5", "")
    _FileWriteLog($logdir, "Info: F5 pressed and Window: " & $window & " was hidden/shown.")
    _ShowHide()
EndFunc

Func _Win6()
    $window = IniRead($inidir, "Window Titles", "Window6", "")
    _FileWriteLog($logdir, "Info: F6 pressed and Window: " & $window & " was hidden/shown.")
    _ShowHide()
EndFunc

Func _Win7()
    $window = IniRead($inidir, "Window Titles", "Window7", "")
    _FileWriteLog($logdir, "Info: F7 pressed and Window: " & $window & " was hidden/shown.")
    _ShowHide()
EndFunc

Func _Win8()
    $window = IniRead($inidir, "Window Titles", "Window8", "")
    _FileWriteLog($logdir, "Info: F8 pressed and Window: " & $window & " was hidden/shown.")
    _ShowHide()
EndFunc

Func _Win9()
    $window = IniRead($inidir, "Window Titles", "Window9", "")
    _FileWriteLog($logdir, "Info: F9 pressed and Window: " & $window & " was hidden/shown.")
    _ShowHide()
EndFunc

Func _Win10()
    $window = IniRead($inidir, "Window Titles", "Window10", "")
    _FileWriteLog($logdir, "Info: F10 pressed and Window: " & $window & " was hidden/shown.")
    _ShowHide()
EndFunc

Func _Win11()
    $window = IniRead($inidir, "Window Titles", "Window11", "")
    _FileWriteLog($logdir, "Info: F11 pressed and Window: " & $window & " was hidden/shown.")
    _ShowHide()
EndFunc

Func _ShowHide(); main func that will detect if its visible, if so it will hide it, if not it will make it visible
    If Not $window = "" Then; will make sure if there is data in there it wont start the function causing the active window to disapear (just in case)
        Local $state = WinGetState($window, "")
        If BitAnd($state, 2) Then
            WinSetState($window, "", @SW_HIDE)
        Else
            WinSetState($window, "", @SW_SHOW)
        EndIf
    EndIf
EndFunc

Func ExitProg(); exit hotkey func
    MsgBox(64,"WinHider","Thanks for using WinHider!")
    Exit
EndFunc
Edited by tlokz
Link to comment
Share on other sites

Sorry to post my script here but..

I made a program like this a few weeks ago to hide an IE with flash game in it with a press of a button.

Got an option to pause the game when hiding.

The problem with hiding a window base on its title only is that if the title change the window cannot be hide or unhide.

To solve this i use the handle of the window title.

How to use:

- Click on "Get title" button and click on the window you want to hide/show.

- Choose the option if you want to auto save or not. ( usefull if you are playing game with a pause button or a shortcut button )

- Click ok.

Now you just have to press the ` key the button just below the Esc button

You can press Alt + ` to show the config menu again.

To exit show the config menu and press esc.

:)

#NoTrayIcon
#Include <WinAPI.au3>
#include <GUIConstants.au3>

dim $control = 0,$winHandle, $M_Loc[3],$KS,$Status_YN= "Y",$Status_Key="K",$New= 0 

#Region GUI
$Frm_WHT = GUICreate("Window Hide Setup", 299, 195, -1, -1)
GUISetBkColor(0x000000)
GUICtrlCreateLabel("Window Title :",8,8,-1,-1)
GUICtrlSetBkColor(-1,0x000000)
GUICtrlSetColor(-1, 0x00FF00)
$Input_Title = GUICtrlCreateInput("", 8, 25, 281, 21)
GUICtrlSetBkColor(-1,0x000000)
GUICtrlSetColor(-1, 0x00FF00)
;-----------------------------------------------------------
$Group_AP = GUICtrlCreateGroup("  Auto Pause  ", 8, 50, 100, 40)
GUICtrlSetBkColor(-1,0x000000)
GUICtrlSetColor(-1, 0x00FF00)
$R_Yes = GUICtrlCreateRadio("Yes",15,65,40,17)
GUICtrlSetState ($R_Yes, $GUI_CHECKED)
GUICtrlSetBkColor(-1,0x000000)
GUICtrlSetColor(-1, 0x00FF00)
$R_No = GUICtrlCreateRadio("No",60,65,40,17)
GUICtrlSetBkColor(-1,0x000000)
GUICtrlSetColor(-1, 0x00FF00)
GUICtrlCreateGroup("", -99, -99, 1, 1)
;-----------------------------------------------------------
$Group_PT = GUICtrlCreateGroup("  Pause Type  ", 8, 95, 100, 60)
GUICtrlSetBkColor(-1,0x000000)
GUICtrlSetColor(-1, 0x00FF00)
$R_M = GUICtrlCreateRadio("Mouse",15,110,50,17)
GUICtrlSetBkColor(-1,0x000000)
GUICtrlSetColor(-1, 0x00FF00)
$R_K = GUICtrlCreateRadio("Keyboard",15,130,80,17)
GUICtrlSetBkColor(-1,0x000000)
GUICtrlSetColor(-1, 0x00FF00)
GUICtrlSetState ($R_K, $GUI_CHECKED)
GUICtrlCreateGroup("", -99, -99, 1, 1)
;-----------------------------------------------------------
$Group_M = GUICtrlCreateGroup("  Mouse  ", 115, 50, 80, 105)
GUICtrlSetBkColor(-1,0x000000)
GUICtrlSetColor(-1, 0x00FF00)
$lbl_M_X =  GUICtrlCreateLabel("X :",125,75,15,11)
GUICtrlSetBkColor(-1,0x000000)
GUICtrlSetColor(-1, 0x00FF00)
$lbl_M_Y = GUICtrlCreateLabel("Y :",125,100,15,11)
GUICtrlSetBkColor(-1,0x000000)
GUICtrlSetColor(-1, 0x00FF00)
$Input_X = GUICtrlCreateInput("", 145, 73, 40, 17,BitOR($ES_CENTER,$ES_AUTOHSCROLL))
GUICtrlSetBkColor(-1,0x000000)
GUICtrlSetColor(-1, 0x00FF00)
$Input_Y = GUICtrlCreateInput("", 145, 98, 40, 17,BitOR($ES_CENTER,$ES_AUTOHSCROLL))
GUICtrlSetBkColor(-1,0x000000)
GUICtrlSetColor(-1, 0x00FF00)
$BTN_GetMouse = GUICtrlCreateButton("Get Mouse", 125, 125, 64, 20, 0)
GUICtrlSetBkColor(-1,0x000000)
GUICtrlSetColor(-1, 0x00FF00)
GUICtrlCreateGroup("", -99, -99, 1, 1)
;-----------------------------------------------------------
$Group_K = GUICtrlCreateGroup("  Keyboard  ", 205, 50, 80, 105)
GUICtrlSetBkColor(-1,0x000000)
GUICtrlSetColor(-1, 0x00FF00)
$lbl_K = GUICtrlCreateLabel("Shortcut Key :",210,70,70,15)
GUICtrlSetBkColor(-1,0x000000)
GUICtrlSetColor(-1, 0x00FF00)
$Input_KS = GUICtrlCreateInput("", 220, 90, 40, 17,BitOR($ES_CENTER,$ES_AUTOHSCROLL,$ES_LOWERCASE))
GUICtrlSetBkColor(-1,0x000000)
GUICtrlSetColor(-1, 0x00FF00)
GUICtrlCreateGroup("", -99, -99, 1, 1)

$Btn_Ok = GUICtrlCreateButton("Ok", 70, 165, 75, 25, 0)
GUICtrlSetBkColor(-1,0x000000)
GUICtrlSetColor(-1, 0x00FF00)
$Btn_Title = GUICtrlCreateButton("Get Title", 150, 165, 75, 25, 0)
GUICtrlSetBkColor(-1,0x000000)
GUICtrlSetColor(-1, 0x00FF00)
GUISetState(@SW_SHOW,$Frm_WHT)
WinSetOnTop($Frm_WHT,"",1)

GUICtrlSetState($Group_K,$GUI_ENABLE)
GUICtrlSetState($Input_KS,$GUI_ENABLE)
GUICtrlSetState($lbl_K,$GUI_ENABLE)
GUICtrlSetState($lbl_M_X,$GUI_DISABLE)
GUICtrlSetState($lbl_M_Y,$GUI_DISABLE)
GUICtrlSetState($Group_M,$GUI_DISABLE)
GUICtrlSetState($Input_X,$GUI_DISABLE)
GUICtrlSetState($Input_Y,$GUI_DISABLE)
GUICtrlSetState($BTN_GetMouse,$GUI_DISABLE)
GUICtrlSetState($Group_PT,$GUI_ENABLE)
GUICtrlSetState($R_M,$GUI_ENABLE)
GUICtrlSetState($R_K,$GUI_ENABLE)
#EndRegion 

While 1
    HotKeySet("!`","Show")
    HotKeySet("`","Control")

    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            If $Input_Title = "" Then ContinueCase
            GUISetState(@SW_HIDE,$Frm_WHT)
            WinSetOnTop($Frm_WHT,"",0)
        Case $Btn_Ok
            If $Input_Title = "" Then ContinueCase
            Btn_OK()
        Case $Btn_Title
            
            For $i = 3 to 0 Step -1
                ToolTip("Click On A Window",@DesktopWidth/2 - 50,@DesktopHeight/2,"Count Down "& $i)
                Sleep(1000)
            Next
            ToolTip("")
            GUICtrlSetData($Input_Title,WinGetTitle(_WinAPI_GetForegroundWindow(),""))
            $New = 1
        Case $BTN_GetMouse
            For $i = 3 to 0 Step -1
                ToolTip("Move Mouse On The Pause Button",@DesktopWidth/2 - 50,@DesktopHeight/2,"Count Down "& $i)
                Sleep(1000)
            Next
            ToolTip("")
            $pos = MouseGetPos()
            GUICtrlSetData($Input_X, $pos[0])
            GUICtrlSetData($Input_Y, $pos[1])
            $M_Loc[0] =$pos[0]
            $M_Loc[1] =$pos[1]
            
        Case $R_M
            $Status_Key = "M"
            GUICtrlSetState($Group_K,$GUI_DISABLE)
            GUICtrlSetState($Input_KS,$GUI_DISABLE)
            GUICtrlSetState($lbl_K,$GUI_DISABLE)
            GUICtrlSetState($lbl_M_X,$GUI_ENABLE)
            GUICtrlSetState($lbl_M_Y,$GUI_ENABLE)
            GUICtrlSetState($Group_M,$GUI_ENABLE)
            GUICtrlSetState($Input_X,$GUI_ENABLE)
            GUICtrlSetState($Input_Y,$GUI_ENABLE)
            GUICtrlSetState($BTN_GetMouse,$GUI_ENABLE)
        Case $R_K
            $Status_Key = "K"
            GUICtrlSetState($Group_K,$GUI_ENABLE)
            GUICtrlSetState($Input_KS,$GUI_ENABLE)
            GUICtrlSetState($lbl_K,$GUI_ENABLE)
            GUICtrlSetState($lbl_M_X,$GUI_DISABLE)
            GUICtrlSetState($lbl_M_Y,$GUI_DISABLE)
            GUICtrlSetState($Group_M,$GUI_DISABLE)
            GUICtrlSetState($Input_X,$GUI_DISABLE)
            GUICtrlSetState($Input_Y,$GUI_DISABLE)
            GUICtrlSetState($BTN_GetMouse,$GUI_DISABLE)
        Case $R_Yes
            $Status_YN = "Y"
            if $Status_Key = "K" Then
                GUICtrlSetState($Group_K,$GUI_ENABLE)
                GUICtrlSetState($Input_KS,$GUI_ENABLE)
                GUICtrlSetState($lbl_K,$GUI_ENABLE)
                GUICtrlSetState($lbl_M_X,$GUI_DISABLE)
                GUICtrlSetState($lbl_M_Y,$GUI_DISABLE)
                GUICtrlSetState($Group_M,$GUI_DISABLE)
                GUICtrlSetState($Input_X,$GUI_DISABLE)
                GUICtrlSetState($Input_Y,$GUI_DISABLE)
                GUICtrlSetState($BTN_GetMouse,$GUI_DISABLE)
                GUICtrlSetState($Group_PT,$GUI_ENABLE)
                GUICtrlSetState($R_M,$GUI_ENABLE)
                GUICtrlSetState($R_K,$GUI_ENABLE)
            ElseIf $Status_Key = "M" Then
                GUICtrlSetState($Group_K,$GUI_DISABLE)
                GUICtrlSetState($Input_KS,$GUI_DISABLE)
                GUICtrlSetState($lbl_K,$GUI_DISABLE)
                GUICtrlSetState($lbl_M_X,$GUI_ENABLE)
                GUICtrlSetState($lbl_M_Y,$GUI_ENABLE)
                GUICtrlSetState($Group_M,$GUI_ENABLE)
                GUICtrlSetState($Input_X,$GUI_ENABLE)
                GUICtrlSetState($Input_Y,$GUI_ENABLE)
                GUICtrlSetState($BTN_GetMouse,$GUI_ENABLE)
                GUICtrlSetState($Group_PT,$GUI_ENABLE)
                GUICtrlSetState($R_M,$GUI_ENABLE)
                GUICtrlSetState($R_K,$GUI_ENABLE)
            EndIf
            
        Case $R_No
            $Status_YN = "N"
            GUICtrlSetState($Group_K,$GUI_DISABLE)
            GUICtrlSetState($Input_KS,$GUI_DISABLE)
            GUICtrlSetState($lbl_K,$GUI_DISABLE)
            GUICtrlSetState($lbl_M_X,$GUI_DISABLE)
            GUICtrlSetState($lbl_M_Y,$GUI_DISABLE)
            GUICtrlSetState($Group_M,$GUI_DISABLE)
            GUICtrlSetState($Input_X,$GUI_DISABLE)
            GUICtrlSetState($Input_Y,$GUI_DISABLE)
            GUICtrlSetState($BTN_GetMouse,$GUI_DISABLE)
            GUICtrlSetState($Group_PT,$GUI_DISABLE)
            GUICtrlSetState($R_M,$GUI_DISABLE)
            GUICtrlSetState($R_K,$GUI_DISABLE)
            
    EndSwitch
    
    
    if WinActive($Frm_WHT,"") Then
        HotKeySet("{esc}","_Exit")
        HotKeySet("{Enter}","Btn_OK")
    Else
        HotKeySet("{esc}")
        HotKeySet("{Enter}")
    EndIf
    
WEnd

Func Btn_OK()
    If $New = 1 Then
        $winHandle = WinGetHandle(GUICtrlRead($Input_Title),"")
        $New = 0
    EndIf
    $M_Loc[0] =GUICtrlRead($Input_X)
    $M_Loc[1] =GUICtrlRead($Input_Y)
    $KS = GUICtrlRead($Input_KS)
    GUISetState(@SW_HIDE,$Frm_WHT)
    WinSetOnTop($Frm_WHT,"",0)
EndFunc

Func Show()
    GUISetState(@SW_SHOW,$Frm_WHT)
    WinSetOnTop($Frm_WHT,"",1)
EndFunc

Func Control()
    If $control = 0 Then
        If $Status_YN = "Y" Then
            
            If $Status_Key = "K" Then
                Send($KS)
            Elseif $Status_Key = "M" Then
                $now = MouseGetPos()
                MouseClick("left",$M_Loc[0],$M_Loc[1],1,0)
                MouseMove($now[0],$now[1],0)
            EndIf
        EndIf
        WinSetState($winHandle,"",@SW_DISABLE)
        WinSetState($winHandle,"",@SW_HIDE )
        WinActivate(_WinAPI_GetForegroundWindow(),"")
        $control = 1
    ElseIf $control = 1 Then
        WinSetState($winHandle,"",@SW_ENABLE )
        WinSetState($winHandle,"",@SW_SHOW )
        WinActivate($winHandle,"")
        If $Status_YN = "Y" Then
            If $Status_Key = "K" Then
                Send($KS)
            Elseif $Status_Key = "M" Then
                $now = MouseGetPos()
                MouseClick("left",$M_Loc[0],$M_Loc[1],1,0)
                MouseMove($now[0],$now[1],0)
            EndIf
        EndIf
        $control = 0
    EndIf
        
EndFunc

Func _Exit()
    WinSetState($winHandle,"",@SW_ENABLE )
    WinSetState($winHandle,"",@SW_SHOW )
    Exit
EndFunc
Edited by DarkNet
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

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