What's wrong with this AHK code? - Overclock.net - An Overclocking Community

Forum Jump: 

What's wrong with this AHK code?

 
Thread Tools
post #1 of 1 (permalink) Old 08-03-2016, 09:16 PM - Thread Starter
New to Overclock.net
 
Tagkaman's Avatar
 
Join Date: Nov 2012
Location: Somwhere in Australia
Posts: 924
Rep: 36 (Unique: 31)
Hi guys! Trying to write an AHK script and my if statements don't seem to be working. The objective of this particular section is:
- When the shortcut (eg. Caps+c) is pressed, switch to the window if it exists
- Else, create a chrome window

Now the switching works but the second half of the statement involving the creation of a window doesn't. Its not a problem with the window creation because if I swap them it works.

This is all relevant code:
Code:
;Capslock modifier
        $*Capslock:: ; when capslock is pressed create an invisible window
        press :=  ; clear press variable
        Gui, 99:+ToolWindow
        Gui, 99:Show,NoActivate x-1 w1 , Capslock Is Down
        keywait, Capslock
        Gui, 99:Destroy ; destroy window when capslock is released
        if (press = "" ){ ; if a hotkey was not pressed, toggle CAPSLOCK
                SetCapsLockState, % (State:=!State) ? "On" : "Off"
        }       
        return

;Move to window
        ToggleWinMinimize(TheWindowTitle)
        {
        SetTitleMatchMode,2
        DetectHiddenWindows, Off
        IfWinActive, %TheWindowTitle%
        {
        WinMinimize, %TheWindowTitle%
        }
        Else
        {
        IfWinExist, %TheWindowTitle%
        {
        WinGet, winid, ID, %TheWindowTitle%
        DllCall("SwitchToThisWindow", "UInt", winid, "UInt", 1)
        }
        }
        Return
        }

#IfWinExist Capslock Is Down  ; enable the following hotkeys while invisible Capslock window exists
        ;App launch
        c::
        IfWinExist, %chrome%
        {
                ToggleWinMinimize("Google Chrome")
                press = true
                return
        }
        else
        {
                Run "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"
                press = true
                return
        }
#IfWinExist

Any ideas?

My Groups (Click to show)
Quote:
I think the only thing that matters in life is just participating in this world (not just the OCN community) and being completely focused on the people while ignoring all of the superficial things. I believe that we are all here for each other, not for ourselves. It's like a famous man once said: judge people by the content of their character.
-Twocables
Tagkaman is offline  
Sponsored Links
Advertisement
 
Reply

Quick Reply
Message:
Options

Register Now

In order to be able to post messages on the Overclock.net - An Overclocking Community forums, you must first register.
Please enter your desired user name, your email address and other required details in the form below.
User Name:
If you do not want to register, fill this field only and the name will be used as user name for your post.
Password
Please enter a password for your user account. Note that passwords are case-sensitive.
Password:
Confirm Password:
Email Address
Please enter a valid email address for yourself.
Email Address:

Log-in



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Show Printable Version Show Printable Version
Email this Page Email this Page


Forum Jump: 

Posting Rules  
You may post new threads
You may post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off