Sign in to follow this  
Followers 0
monte

child gui (create)

4 posts in this topic

hello, I'm having trouble with creating a separate gui from within my main gui. I call my main gui, then call my child gui (file,hotkeys). My child gui opens, I'm able to enter data and press ok or cancel and my child gui closes. However, at this point my main gui freezes and I have to kill the whole script! How do I give control back to my main gui without crashing it?! I've tried various options and here's what I currently have, thanks.:

#include <GUIConstants.au3>
#include <array.au3>
#notrayicon
$checkRun = "Emc Tool"
If WinExists($checkRun) Then Exit

$main_gui= GUICreate("Emc Tool", 350, 260)
Global $defaultstatus = "Ready"
Global $status

$filemenu = GUICtrlCreateMenu ("&File")
$filehotkeyitem = GUICtrlCreateMenuitem ("&Hot Keys",$filemenu)
$fileexititem = GUICtrlCreateMenuitem ("E&xit",$filemenu)
$helpmenu = GUICtrlCreateMenu ("&Help")
$helpreadmeitem = GUICtrlCreatemenuitem ("&Readme",$helpmenu)
$separator1 = GUICtrlCreateMenuitem ("",$filemenu,2); create a separator line
GUICtrlSetState(-1,$GUI_FOCUS)
$statuslabel = GUICtrlCreateLabel ($defaultstatus,0,220,350,18,BitOr($SS_SIMPLE,$SS_SUNKEN))

$button1 = GUICtrlCreateIcon ("C:\progra~1\pa.bmp",-1,10,10)
GUISetState ()

While 1
   $msg = GUIGetMsg()
   If $msg = $GUI_EVENT_CLOSE Or $msg = $fileexititem Then ExitLoop
   If $msg = $helpreadmeitem Then
    $str0=(' /c "' & @programfilesdir & '\EMC TOOL\readme.txt"')
    dim $st[5]
    $st[1]= @ComSpec
    $st[2]= $str0
    $st[3]= ""
    $st[4]= @SW_HIDE
    run($st[1] & $st[2], $st[3], $st[4])
   endif

   If $msg = $filehotkeyitem then
    $str=('"' & @programfilesdir & '\EMC Tool\userHotKeys.txt"')
    If FileExists($str) then
    ;read code goes here
     guiswitch($hotkeyGui)   
    else
     $hotkeyGui=GUICreate("EMC Tool User Defined HotKeys", 320,725,-1,-1,0x00000200,)
     guiswitch($hotkeyGui)
     GUICtrlCreatelabel ("Usage Identifiers:",8,01)
     GUICtrlCreatelabel ("Shift = shift, Control = ctrl, Alt = alt",100,01)
     GUICtrlCreatelabel ("Place a '+' between each identifier",100,14)
     GUICtrlCreatelabel ("Example:",08,35)
     GUICtrlCreatelabel ("Shift + F5 = shift+F5",100,35)
     GUICtrlCreatelabel ("Control + s = ctrl+s",100,48)
     GUICtrlCreatelabel ("Control + Alt + w = ctrl+alt+w",100,48)
     GUICtrlCreatelabel ("Private Ark",10,80,150,20)
      $hotkeyprivateArk = GUICtrlCreateInput ("", 160,  75, 100, 20)
      GUICtrlRead($hotkeypa)
      $btn0 = GUICtrlCreateButton ("OK", 30, 675, 40, 20)
      $btn1 = GUICtrlCreateButton ("Close",80, 675, 40,20)
      GUISetState () 
      while 1
      $msg = GUIGetMsg()
      If $msg = $GUI_EVENT_CLOSE then guidelete($hotkeyGui)
      IF $msg = $btn1 then guidelete($hotkeyGui)
      Select
        Case $msg = $btn0
          $str=('"' & @programfilesdir & '\EMC Tool\userHotKeys.txt"')
          msgbox(0,"",$str)
          If FileExists($str) then
           ;read
          else
            $hotkeyfile=fileopen($str,1)
            if $hotkeyfile = -1 then
              msgbox(0,"Error","Unable to open file.")
              guiswitch($main_gui)
              guidelete($hotkeyGui)
            else
              filewriteline($hotkeyfile,GUICtrlRead($hotkeypa))
              guiswitch($main_gui)
              guidelete($hotkeyGui)
            endif
            fileclose($hotkeyfile)
          endif
      EndSelect
     Wend
    endif
   endif

   Select
      Case $msg = $button1
         pa()
   EndSelect
WEnd

;;;;;;

func pa()
 If WinExists("Pa") Then
  $vServerClip=clipget()
  $vServerString = StringSplit($vServerClip, @TAB)
  If $vServerString[0] >= 22 Then 
   $statuslabel = GUICtrlCreateLabel ("opening pa",0,220,350,18,BitOr($SS_SIMPLE,$SS_SUNKEN))
   $vServer = $vServerString[22]
   WinActivate("pa")
   sleep(1000)
   Send("{F10}tf")
   Send($vServer)
   send("{TAB}a")
   Send("{ENTER}")
   sleep(1000)
   send("{ENTER}")
  else 
   msgbox(1,"EMC TOOL", "Please copy the alert into the clipboard.")
  endif
 else
  $vServerClip=clipget()
  $vServerString = StringSplit($vServerClip, @TAB)
  If $vServerString[0] >= 22 Then 
   $statuslabel = GUICtrlCreateLabel ("opening pa",0,220,350,18,BitOr($SS_SIMPLE,$SS_SUNKEN))
   global $mycmd="C:\progra~1\citrix\icacli~1\pn.exe /pn:" & '"farm"' & ' /app:"pa Client"'
   Dim $primary
   Dim $secondary
   $k = RegRead("HKEY_CURRENT_USER\Control Panel\Mouse", "SwapMouseButtons")
   If $k = 1 Then
    $primary = "right"
    $secondary = "left"
   else 
    $primary = "left"
    $secondary = "right"
   endIf
   msgbox(1,"","Opening pa, please have your rsa token ready.  If the server search does not commence upon entering, please reclick the pa icon.", 20)
   run($mycmd)
   WinWaitActive("pa")
   winactivate("pa")
   MouseClick($Primary, 160,140, 2, 0)
   sleep(20000)
   winactivate("pa")
   $vServer = $vServerString[22]
   Send("{F10}tf")
   Send($vServer)
   send("{TAB}a")
   Send("{ENTER}")
   sleep(1000)
   send("{ENTER}")
   sleep(300)
  else
   msgbox(1,"EMC TOOL", "Please copy the alert into the clipboard.")
  endif
 endif
   $statuslabel = GUICtrlCreateLabel ("Ready                                                                         ",0,220,350,18,BitOr($SS_SIMPLE,$SS_SUNKEN))
endfunc

Share this post


Link to post
Share on other sites



Is it possible to create my hotkeygui (child gui) with a separate process id?

Share this post


Link to post
Share on other sites

save your old code, and give this a try

#include <GUIConstants.au3>
#include <array.au3>
#notrayicon
$checkRun = "Emc Tool"
If WinExists($checkRun) Then Exit

$main_gui = GUICreate("Emc Tool", 350, 260)
Global $defaultstatus = "Ready"
Global $status

$filemenu = GUICtrlCreateMenu("&File")
$filehotkeyitem = GUICtrlCreateMenuItem("&Hot Keys", $filemenu)
$fileexititem = GUICtrlCreateMenuItem("E&xit", $filemenu)
$helpmenu = GUICtrlCreateMenu("&Help")
$helpreadmeitem = GUICtrlCreateMenuItem("&Readme", $helpmenu)
$separator1 = GUICtrlCreateMenuItem("", $filemenu, 2); create a separator line
GUICtrlSetState(-1, $GUI_FOCUS)
$statuslabel = GUICtrlCreateLabel($defaultstatus, 0, 220, 350, 18, BitOR($SS_SIMPLE, $SS_SUNKEN))

$button1 = GUICtrlCreateIcon("shell32.dll", 1, 10, 10)
GUISetState()

While 1
 $msg = GUIGetMsg()
 Select
  Case $msg = $GUI_EVENT_CLOSE Or $msg = $fileexititem
   ExitLoop
  Case $msg = $helpreadmeitem
   $str0= (' /c "' & @ProgramFilesDir & '\EMC TOOL\readme.txt"')
   Dim $st[5]
   $st[1] = @ComSpec
   $st[2] = $str0
   $st[3] = ""
   $st[4] = @SW_HIDE
   Run($st[1] & $st[2], $st[3], $st[4])
   
  Case $msg = $filehotkeyitem
   GUISetState(@SW_DISABLE, $main_gui)
   $str= ('"' & @ProgramFilesDir & '\EMC Tool\userHotKeys.txt"')
  ;read code goes here
   $hotkeyGui = GUICreate("EMC Tool User Defined HotKeys", 320, 725, -1, -1, 0x00000200)
   GUICtrlCreateLabel("Usage Identifiers:", 8, 01)
   GUICtrlCreateLabel("Shift = shift, Control = ctrl, Alt = alt", 100, 01)
   GUICtrlCreateLabel("Place a '+' between each identifier", 100, 14)
   GUICtrlCreateLabel("Example:", 08, 35)
   GUICtrlCreateLabel("Shift + F5 = shift+F5", 100, 35)
   GUICtrlCreateLabel("Control + s = ctrl+s", 100, 48)
   GUICtrlCreateLabel("Control + Alt + w = ctrl+alt+w", 100, 48)
   GUICtrlCreateLabel("Private Ark", 10, 80, 150, 20)
   $hotkeyprivateArk = GUICtrlCreateInput("", 160, 75, 100, 20)
;~  GUICtrlRead($hotkeypa)
   $btn0 = GUICtrlCreateButton("OK", 30, 675, 40, 20)
   $btn1 = GUICtrlCreateButton("Close", 80, 675, 40, 20)
   GUISetState(@SW_SHOW, $hotkeyGui)
   While 1
    $msg2 = GUIGetMsg()
    Select
     Case $msg2 = $GUI_EVENT_CLOSE Or $msg2 = $btn1
      ExitLoop
     Case $msg2 = $btn0
      $str= ('"' & @ProgramFilesDir & '\EMC Tool\userHotKeys.txt"')
      MsgBox(0, "", $str)
      If FileExists($str) Then
      ;read
      Else
       $hotkeyfile = FileOpen($str, 1)
       If $hotkeyfile = -1 Then
        MsgBox(0, "Error", "Unable to open file.")
        ExitLoop
       Else
;~       FileWriteLine($hotkeyfile, GUICtrlRead($hotkeypa))
        ExitLoop
       EndIf
       FileClose($hotkeyfile)
      EndIf
    EndSelect
   WEnd
   GUISetState(@SW_ENABLE, $main_gui)
   GUIDelete($hotkeyGui)
   GUISetState(@SW_SHOW, $main_gui)
   
  Case $msg = $button1
   pa()
 EndSelect
WEnd

;;;;;;

Func pa()
 If WinExists("Pa") Then
  $vServerClip = ClipGet()
  $vServerString = StringSplit($vServerClip, @TAB)
  If $vServerString[0] >= 22 Then
   $statuslabel = GUICtrlCreateLabel("opening pa", 0, 220, 350, 18, BitOR($SS_SIMPLE, $SS_SUNKEN))
   $vServer = $vServerString[22]
   WinActivate("pa")
   Sleep(1000)
   Send("{F10}tf")
   Send($vServer)
   Send("{TAB}a")
   Send("{ENTER}")
   Sleep(1000)
   Send("{ENTER}")
  Else
   MsgBox(1, "EMC TOOL", "Please copy the alert into the clipboard.")
  EndIf
 Else
  $vServerClip = ClipGet()
  $vServerString = StringSplit($vServerClip, @TAB)
  If $vServerString[0] >= 22 Then
   $statuslabel = GUICtrlCreateLabel("opening pa", 0, 220, 350, 18, BitOR($SS_SIMPLE, $SS_SUNKEN))
   Global $mycmd = "C:\progra~1\citrix\icacli~1\pn.exe /pn:" & '"farm"' & ' /app:"pa Client"'
   Dim $primary
   Dim $secondary
   $k = RegRead("HKEY_CURRENT_USER\Control Panel\Mouse", "SwapMouseButtons")
   If $k = 1 Then
    $primary = "right"
    $secondary = "left"
   Else
    $primary = "left"
    $secondary = "right"
   EndIf
   MsgBox(1, "", "Opening pa, please have your rsa token ready.  If the server search does not commence upon entering, please reclick the pa icon.", 20)
   Run($mycmd)
   WinWaitActive("pa")
   WinActivate("pa")
   MouseClick($primary, 160, 140, 2, 0)
   Sleep(20000)
   WinActivate("pa")
   $vServer = $vServerString[22]
   Send("{F10}tf")
   Send($vServer)
   Send("{TAB}a")
   Send("{ENTER}")
   Sleep(1000)
   Send("{ENTER}")
   Sleep(300)
  Else
   MsgBox(1, "EMC TOOL", "Please copy the alert into the clipboard.")
  EndIf
 EndIf
 $statuslabel = GUICtrlCreateLabel("Ready                                                                        ", 0, 220, 350, 18, BitOR($SS_SIMPLE, $SS_SUNKEN))
EndFunc  ;==>pa

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

gafrost, you're AWESOME! I'be posted here before for exactly the same issue....I appreciate your help!

Share this post


Link to post
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
Sign in to follow this  
Followers 0