Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Posting a QM folder to the forum
#1
Sometimes you want to post multiple functions to the forum. Then you create new QM folder, move the functions there, export the folder to a file, and attach the file to the topic.

This macro automates exporting and attaching. Select (click) the folder, and run this macro. It exports the folder to a temporary file and attaches it to the post you are creating.

Works with IE (tested with IE 7 on Vista) and FF (tested with FF 3.0.1 on Vista). Requires QM 2.3.0 or later. Tested only with the default forum theme.

2011.04.13
Updated to work with IE9 and FF4.

Macro PostMacrosToForum
Code:
Copy      Help
;1. In QM.

;get selected item in qm items list
int htv=id(2202 _hwndqm)
int iid=TvGetParam(htv SendMessage(htv TVM_GETNEXTITEM TVGN_CARET 0))

;is it folder?
_s.getmacro(iid 3)
if(_s!=5) ;;not folder
,mes "This macro attaches a QM folder to the post in the forum. Please select the folder and run this macro again.[][]If you want to post a single macro, instead use menu Edit -> Other Formats."
,ret

;temporary file path
str name.getmacro(iid 1)
str tfile.from("$temp$\qmexport\" _s.RandomString(10 10 "qwertyuiopasdfghjkl") "\" name ".qml") ;;why we use random folder? because FF does not close the file, and then next time SilenExport fails.
tfile.expandpath
;out tfile; ret

;export the folder to the file
del "$temp$\qmexport"; err
if(!SilentExport(+iid tfile 2)) mes- "failed to export the folder"

;out items
str items
GetQmFolderItems +iid items
out "FUNCTIONS:[]%s" items

;out word list
str words
GetQmFolderWordList +iid words
out "[size=1]WORD LIST: %s[/size]" words

;ret
;---------------------

;2. In browser.

;activate browser (firefox or internet explorer)
int ie; Acc a adoc
int hwnd=win("Quick Macros Forum" "Mozilla*WindowClass" "" 0x804)
if(!hwnd) hwnd=win("Quick Macros Forum" "IEFrame"); if(hwnd) ie=1; else goto ge1
act hwnd
0.3

if(ie) adoc=acc("" "PANE" hwnd "Internet Explorer_Server" "" 0x1000)
else adoc=acc("" "DOCUMENT" hwnd "" "" 0x1080)

;click 'Upload attachment'
a=acc("Upload attachment" "LINK" adoc "" "" 0x1011); err goto ge1
a.DoDefaultAction

;type the file path
;a=acc("Browse*" "PUSHBUTTON" a "" "" 0x1091 0 0 "previous")
;a.SetValue(tfile) ;;does not work with file input elements
;a.Select(1) ;;in FF works but I cannot type text; is the edit field readonly?
;a.Mouse(1) ;;also cannot be used in FF because it opens the dialog
;so we have to click Browse...
a=acc(iif(ie "Filename:" "Browse*") "PUSHBUTTON" adoc "" "" 0x1011)

0.5
a.DoDefaultAction
int hfu
if(ie) wait(10 WA win("Choose file*" "#32770" "IEXPLORE" 3))
else hfu=wait(10 WA win("File Upload" "" "FIREFOX" 3))
key (0.3) (tfile) (0.3) Y (0.1)

;click 'Add the file' button
;a.Navigate(iif(ie "next2" "parent next2"))
;a.DoDefaultAction
;disabled the above code to allow you to click either 'Add the file' or 'Update file'

ret
;ge1
mes "Internet Explorer or Firefox must be running, with 'Post a new topic' or similar page in QM forum."
#2
Had to tweek...
Windows XP
Firefox/2.0.0.16


First had to make sure forum was set to prosilver theme.
Second had to add:

Acc b=acc("Add the file" "PUSHBUTTON" win("Quick Macros Forum • Post a reply - Mozilla Firefox" "MozillaUIWindowClass") "MozillaWindowClass" "" 0x1001)
b.DoDefaultAction
in place of:
a.Navigate(iif(ie "next2" "parent next2"))
a.DoDefaultAction

Other than that...ran good.


Attached Files
.qml   Uploaded folder.qml (Size: 2.43 KB / Downloads: 599)
#3
Just tried this and I have to say it is way to cool and I will start using it. Very nice job.
#4
This version also displays word list in output. Paste it in the post to make the attachment searchable.
Also it does not press 'Add file' button. After you run the macro, you can press either 'Add file' or 'Update file' button.

WORD LIST:
_hwndqm above Acc act activate Add again allow also and ARRAY attaches attachment because Browse browser but button cannot Choose click close cls code continue CreateStringMap del dialog disabled DoDefaultAction does Edit either elements else EnumQmFolder err expandpath explorer Explorer_Server export failed fails field file Filename findreplace firefox folder for Formats forum from function ge1 get GetList getmacro GetQmFolderWordList goto GQFWL_Enum have hfu hItem htv hwnd IEFrame iid iif input instead int internet isdigit IStringMap item items key len level LINK list lParam macro Macros mask menu mes Mouse MozillaContentWindowClass MozillaUIWindowClass must name Navigate new next next2 not opens Other out page parent path Please post PostMacrosToForum previous PUSHBUTTON qmexport QMITEM qml Quick qwertyuiopasdfghjkl random RandomString readonly rep ret run running select selected SendMessage SetValue SilenExport SilentExport similar single str temp temporary text tfile the then This
time tok topic TVGN_CARET TVIF_PARAM TVITEMEX TVM_GETITEM TVM_GETNEXTITEM type Update Upload use used wait want why win with word words work works wrap you


Attached Files
.qml   post qm folder to forum.qml (Size: 2.73 KB / Downloads: 578)


Forum Jump:


Users browsing this thread: 1 Guest(s)