1

CtrlSSMS (SQL Server Management Studio) では、タブを中クリックするか、 +を押しF4て現在のエディター タブを閉じる必要があります。Autoitショートカットを作成するために使用したいCtrl+w同じことをします。しかし、私はそれに問題があります。以下はコードです。私が考えたのは、ユーザーがCtrl+wを押したときに、ユーザーが にいるかどうかを確認しSSMS、そうであればCtrl+を送信F4して現在のタブを閉じ、そうでない場合はCtrl+wを送信して通常どおりに行かせることです。ただ、ポイントはCtrl+を送るwと再度 Autoit に取り込まれてしまうので、デッドループが発生します。この問題を解決する方法が見つかりません。誰でも私を助けることができますか?

ありがとう。

HotKeySet("^w", "close_ssms_editor")

While 1
    Sleep(200)
WEnd

; using Ctrl + w to close
; * editors in SSMS
; * editors in SSMS through Royal TS
Func close_ssms_editor()
    $window_class_name = get_window_class_name(WinGetHandle(""))
    If $window_class_name = "wndclass_desked_gsk" or $window_class_name = "WindowsForms10.Window.8.app.0.218f99c" Then
        Send("^{F4}")
    Else
        Send("^w")
    EndIf
EndFunc


Func get_window_class_name($nCtrl)
    If Not IsHWnd($nCtrl) then $nCtrl = HWnd($nCtrl)
    Local $struct = DllStructCreate("char[128]"),$classname = 0
    $ret = DllCall("user32.dll","int","GetClassName","hwnd",$nCtrl,"ptr",DllStructGetPtr($struct),"int",DllStructGetSize($struct))
    If IsArray($ret) Then
        $classname = DllStructGetData($struct,1)
        While (StringIsDigit(StringRight($classname,1)))
            $classname = StringTrimRight($classname,1)
        WEnd
    EndIf
    $struct =0 
    Return $classname
EndFunc
4

1 に答える 1

1

私は解決策を見つけました。

; using Ctrl + w to close
; * editor in SSMS
; * editor in SSMS through Royal TS
Func close_ssms_editor()
    $window_class_name = get_window_class_name(WinGetHandle(""))
    If $window_class_name = "wndclass_desked_gsk" or $window_class_name = "WindowsForms10.Window.8.app.0.218f99c" Then
        Send("^{F4}")
    Else
        HotKeySet("^w")
        Send("^w")
        HotKeySet("^w", "close_ssms_editor")
    EndIf
EndFunc
于 2011-03-21T04:42:31.047 に答える