Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
New to this and could use some help/input
#1
First off I am new to Quick Macros and am not the best at writing code but I can read and understand alot of it. I am trying to make a dialog that you enter information in and select ok it will open Putty and load a saved session and follow certain commands. I got everything working but am unable to figure out how to make it where the dialog box does not exit when the ok button is pressed. Everything works all in 1 macro other than the ok button. Here is an example of the code and I'm sure there is a much easier way to do it then the way I have it now but I am open to suggestions and have been searching the forums for over a week and have been trying to learn and figure this out on my own but am completely stumped


Code:
Copy      Help
\Dialog_Editor

opt err 1 ;;on error continue
spe 0600 ;;wait 1 second after commands

;Dialog box on startup
str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 136 56 "BOX"
;6 Edit 0x54032000 0x200 52 20 32 13 ""
;3 Static 0x54000000 0x0 0 0 140 22 "NUMBER?"
;1 Button 0x54030001 0x4 4 36 48 14 "OK"
;2 Button 0x54030000 0x4 84 36 48 14 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2040202 "*" "" "" ""


str controls = "6"
str e6
if(!ShowDialog(dd 0 &controls)) ret


;;Opens putty on the saved session
run "C:\Program Files (x86)\Putty\PUTTY.exe" ("-load session name")

;Wait for Putty window max 5 s
wait 1 WA "PUTTY"
;Wait 1.0 s
1.0

key jumpto V -u V users V -s V isp.0(e6).us ;;command that is ran with the info entered into the dialog as (e6)
key Y ;; enter
key Y ;; enter
key "info"
key Y ;; enter
key F3;; F3
key Y ;; enter
key D ;; down
key Y ;; enter
key D ;; down
key D ;; down
key Y ;; enter
key Y ;; enter
key F12 ;; F12
key Y ;; enter
#2
Let the dialog have a dialog procedure. Also known as "smart dialog".
Let the button have other id, not 1.
Move the part of the macro that sends keys etc to a new macro or #sub.
When the button clicked, start the macro using mac. Get edit control values with str.getwintext and pass them to the macro using function parameters.

Macro Macro2842
Code:
Copy      Help
str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 136 56 "BOX"
;6 Edit 0x54032000 0x200 52 20 32 13 ""
;3 Static 0x54000000 0x0 0 0 140 22 "NUMBER?"
;100 Button 0x54030001 0x4 4 36 48 14 "OK"
;2 Button 0x54030000 0x4 84 36 48 14 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2040202 "*" "" "" ""


str controls = "6"
str e6
if(!ShowDialog(dd &sub.DlgProc &controls)) ret


#sub DlgProc
function# hDlg message wParam lParam

sel message
,case WM_INITDIALOG
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case 100
,str e6.getwintext(id(6 hDlg))
,mac "sub.Macro" "" e6
,
,case IDCANCEL
ret 1


#sub Macro
function str'e6

;out e6; ret
if getopt(nthreads)>1
,if('O'=mes("Stop the macro?" "" "OC")) EndThread +getopt(itemid)
,ret
AddTrayIcon "$qm$\macro.ico" "My macro is running.[]Ctrl+click this icon to end it."

opt err 1 ;;on error continue
spe 0600 ;;wait 1 second after commands

;;Opens putty on the saved session
run "C:\Program Files (x86)\Putty\PUTTY.exe" ("-load session name")

;Wait for Putty window max 5 s
wait 1 WA "PUTTY"
;Wait 1.0 s
1.0

;key jumpto V -u V users V -s V isp.0(e6).us ;;command that is ran with the info entered into the dialog as (e6)
paste F"jumpto -u users -s isp.0{e6}.us"
key Y ;; enter
key Y ;; enter
key "info"
key Y ;; enter
key F3;; F3
key Y ;; enter
key D ;; down
key Y ;; enter
key D ;; down
key D ;; down
key Y ;; enter
key Y ;; enter
key F12 ;; F12
key Y ;; enter
#3
Thank you so much Gintaras I have gotten everything working now. I am new to quickmacros but am loving it, is there a way to to have a message appear if the text entered into control 6 is above a certain number digits? I have tried a few different way and it either always appears no matter how many digits or does not appear at all.
#4
Function Dialog213
Code:
Copy      Help
str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 224 136 "Dialog"
;3 Edit 0x54032000 0x200 8 8 64 12 ""
;1 Button 0x54030001 0x4 116 116 48 14 "OK"
;2 Button 0x54030000 0x4 168 116 48 14 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2040500 "*" "" "" ""

str controls = "3"
str e3
if(!ShowDialog(dd &sub.DlgProc &controls)) ret


#sub DlgProc
function# hDlg message wParam lParam

sel message
,case WM_INITDIALOG
,SendMessage id(3 hDlg) EM_LIMITTEXT 4 0 ;;max 4 characters
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
,case EN_MAXTEXT<<16|3
,mes "Max length 4"
ret 1


Forum Jump:


Users browsing this thread: 1 Guest(s)