Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;wiisync - auto setup tool w00t
- ;written @ 1/11/11 - apocolpyse?
- ; by James Trevaskis http://metasplo.it
- ;includes
- #include-once
- #include <GuiConstantsEx.au3>
- #include <Constants.au3>
- #include <array.au3>
- #include <GuiToolbar.au3>
- #include <WindowsConstants.au3>
- Opt('MustDeclareVars', 1)
- ;message to user
- msgbox(0, "WiiSync Setup Wizard", "Please turn the ON/OFF switch to the ON position." & @LF & @LF & "If it is currently ON, please turn it off, wait 5 seconds, then turn it back on." & @LF & @LF & "Then click OK.")
- ;block input from busy student hands
- blockinput(1)
- msgbox(0, "WiiSync Establishing Connection", "Please wait patiently while the touch interface is established..." & @LF & @LF & "I have kindly disabled your keyboard and mouse to prevent interference with the setup process.", 5)
- ;killing open wiituio
- ProcessClose ( "WiiTUIO.exe" )
- Run("c:\wiimote\process.exe -k wiituio.exe", "")
- sleep(500)
- ;refresh tray notification area
- _RefreshSystemTray(1000)
- sleep(500)
- ;running wiituio
- run("c:\wiimote\wiituio.exe")
- sleep(6500)
- ; popup WinTUIO window
- Global $hSysTray_Handle, $iSystray_ButtonNumber
- Global $sToolTipTitle = "[tool tip here]"
- $iSystray_ButtonNumber = Get_Systray_Index($sToolTipTitle)
- If $iSystray_ButtonNumber = 0 Then
- Global $hSysTray_Handle, $iSystray_ButtonNumber
- ;repeating the process twice as it doesnt always grab first time
- Global $sToolTipTitle = "[tool tip here]"
- $iSystray_ButtonNumber = Get_Systray_Index($sToolTipTitle)
- If $iSystray_ButtonNumber = 0 Then
- msgbox(0, ".", "Connect failed, please rerun WiiSync...", 5)
- Exit
- Else
- Sleep(500)
- _GUICtrlToolbar_ClickButton($hSysTray_Handle, $iSystray_ButtonNumber, "left")
- EndIf
- Else
- Sleep(500)
- _GUICtrlToolbar_ClickButton($hSysTray_Handle, $iSystray_ButtonNumber, "left")
- EndIf
- ;setting up WinTUIO
- sleep(3000)
- send("{tab}{tab}{tab}{+}")
- sleep(1000)
- send("{tab}{tab}{+}")
- sleep(1000)
- send("{tab}{tab}{enter}")
- sleep(2500)
- ;make window disappear
- send("{LWIN}")
- sleep(100)
- send("{LWIN}")
- ;unblock Input
- blockinput(0)
- ;EOF
- msgbox(0, "WiiSync Complete", "Synchronization complete, if the touch interface fails, please re-run WiiSync.")
- Exit
- ;#
- ;#FUNCTIONS
- ;#
- ; ===================================================================
- ; _RefreshSystemTray($nDealy = 1000)
- ;
- ; Removes any dead icons from the notification area.
- ; Parameters:
- ; $nDelay - IN/OPTIONAL - The delay to wait for the notification area to expand with Windows XP's
- ; "Hide Inactive Icons" feature (In milliseconds).
- ; Returns:
- ; Sets @error on failure:
- ; 1 - Tray couldn't be found.
- ; 2 - DllCall error.
- ; ===================================================================
- Func _RefreshSystemTray($nDelay = 1000)
- ; Save Opt settings
- Local $oldMatchMode = Opt("WinTitleMatchMode", 4)
- Local $oldChildMode = Opt("WinSearchChildren", 1)
- Local $error = 0
- Do; Pseudo loop
- Local $hWnd = WinGetHandle("classname=TrayNotifyWnd")
- If @error Then
- $error = 1
- ExitLoop
- EndIf
- Local $hControl = ControlGetHandle($hWnd, "", "Button1")
- ; We're on XP and the Hide Inactive Icons button is there, so expand it
- If $hControl <> "" And ControlCommand($hWnd, "", $hControl, "IsVisible") Then
- ControlClick($hWnd, "", $hControl)
- Sleep($nDelay)
- EndIf
- Local $posStart = MouseGetPos()
- Local $posWin = WinGetPos($hWnd)
- Local $y = $posWin[1]
- While $y < $posWin[3] + $posWin[1]
- Local $x = $posWin[0]
- While $x < $posWin[2] + $posWin[0]
- DllCall("user32.dll", "int", "SetCursorPos", "int", $x, "int", $y)
- If @error Then
- $error = 2
- ExitLoop 3; Jump out of While/While/Do
- EndIf
- $x = $x + 8
- WEnd
- $y = $y + 8
- WEnd
- DllCall("user32.dll", "int", "SetCursorPos", "int", $posStart[0], "int", $posStart[1])
- ; We're on XP so we need to hide the inactive icons again.
- If $hControl <> "" And ControlCommand($hWnd, "", $hControl, "IsVisible") Then
- ControlClick($hWnd, "", $hControl)
- EndIf
- Until 1
- ; Restore Opt settings
- Opt("WinTitleMatchMode", $oldMatchMode)
- Opt("WinSearchChildren", $oldChildMode)
- SetError($error)
- EndFunc; _RefreshSystemTray()
- Func Get_Systray_Index($sToolTipTitle)
- ; Find systray handle
- $hSysTray_Handle = ControlGetHandle('[Class:Shell_TrayWnd]', '', '[Class:ToolbarWindow32;Instance:1]')
- If @error Then
- ;MsgBox(16, "Error", "System tray not found")
- Exit
- EndIf
- ; Get systray item count
- Local $iSystray_ButCount = _GUICtrlToolbar_ButtonCount($hSysTray_Handle)
- If $iSystray_ButCount = 0 Then
- ;MsgBox(16, "Error", "No items found in system tray")
- Exit
- EndIf
- ; Look for wanted tooltip
- For $iSystray_ButtonNumber = 0 To $iSystray_ButCount - 1
- ;msgbox(0, ".", $hSysTray_Handle & @LF & $iSystray_ButtonNumber)
- ;global $testvar = _GUICtrlToolbar_GetButtonText($hSysTray_Handle, $iSystray_ButtonNumber)
- ;msgbox(0, "testvar", "button number: " & $iSystray_ButtonNumber & @LF & "testvar: " & $testvar)
- If StringInStr(_GUICtrlToolbar_GetButtonText($hSysTray_Handle, $iSystray_ButtonNumber), $sToolTipTitle) = 1 Then ExitLoop
- Next
- ;debug
- ;msgbox(0, ".", $iSystray_ButtonNumber)
- If $iSystray_ButtonNumber = $iSystray_ButCount Then
- Return 0 ; Not found
- Else
- Return $iSystray_ButtonNumber ; Found
- EndIf
- EndFunc
Add Comment
Please, Sign In to add comment