AutoHotkey Community

It is currently May 26th, 2012, 3:38 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: March 19th, 2009, 9:45 am 
Offline

Joined: March 17th, 2008, 10:02 pm
Posts: 21
Location: Netherlands
Hi

I tried to make my own msgbox with 2 buttons (go_on and stop) in a gui subroutine.
when i'm calling this sub, it creates the GUI and returns.
The script didn't wait for button press (when you use the prefab msgbox it does), because the button_press is another sub.

I had to make a kind of workaround (with initially do = -1 and a loop to check if do > -1) to solve this - but I don't like that code.
My question: is this the correct way, or do you know a better (shorter) sollution ?

Code:
do = -1

;telnet not default installed in Vista #####

telnet:
GoSub, MsgBox_telnet

Loop,
{   
   if do > -1
      break
   else
      sleep, 100
}

if do = 1
   GoSub, telnet_aan

do = -1
return

; #########################################
; GUI input
MsgBox_telnet:

Gui, Add, Button, x42 y102 w90 h30 gGoOn, DOORGAAN
kleur = EEAA99
Gui, Color, %kleur%
WinSet, TransColor, %kleur% 150
Gui, Add, Button, x182 y102 w90 h30 gSTOP, STOPPEN
Gui, Font, S12 CDefault, Verdana
Gui, Add, Text, x42 y22 w250 h80 , Activating telnet opens ports, are you sure ?
Gui, Show, x127 y87 h172 w315, Telnet activation or installation
Return

STOP:
Gui, destroy
do = 0
return
GuiClose:
do = 0
Gui, destroy
return

GoOn:
do = 1
Gui, destroy
Return

; ############## end gui #####################



/*
###################### Run telnet
telnet_aan:
run, telnet,, UseErrorLevel
if ErrorLevel = ERROR
{
   Gosub, install_telnet
   run, telnet, UseErrorLevel
   if ErrorLevel = ERROR
      msgbox, unknown error
   ErrorLevel =
   return
}
 
return

;######################## Install telnet
install_telnet:
parameter := "control appwiz.cpl,,2"
runwait, %parameter%
sleep, 2000
Loop,
{
   WinGet, Check, ControlList, A
   If Check contains SysTreeView321
      break
   tel += 1
   sleep, 100
   If tel = 80 ; 8 seconden
   {
      msgbox, telnet installatievenster komt niet
      return
   }
}
send telnet-client
send {SPACE}
send {ENTER}
sleep, 3000
Loop,
{
   WinGet, Check, ControlList, A
   If Check contains DirectUIHWND1
      sleep, 100
   Else
      break
}
;##################end telnet
*/

_________________
your eyes are like bright stars in the sea,
you clean the dishes and I watch tv...


Last edited by sterrenstof ('stardust') on March 19th, 2009, 10:37 am, edited 4 times in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 19th, 2009, 10:14 am 
Offline

Joined: June 6th, 2006, 3:19 pm
Posts: 1654
Location: Denmark
Try replacing your Gui, Show with:
Code:
  Gui, Show
  Gui, +LastFound
  hWnd := WinExist()
  WinWaitClose, ahk_id %hWnd%
  Return

_________________
RegEx Powered Dynamic Hotstrings
COM
AutoHotkey 2


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 19th, 2009, 11:04 am 
Offline

Joined: March 17th, 2008, 10:02 pm
Posts: 21
Location: Netherlands
tonne wrote:
Try replacing your Gui, Show with:
...


thnx a lot Tonne, you're right :D
I really searched for this solution, but couldn't find it.

The manual is not very clear on this basic subject, and the forum is difficult to search - too much posts in one cat.

Love Denmark !

_________________
your eyes are like bright stars in the sea,
you clean the dishes and I watch tv...


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 14 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group